Re: C kérdés

Bela Bogdanyi bbog at t-online.hu
Fri Jul 28 12:50:25 CEST 2006


Ez pedig a GNU leírásból való:

/*********************************/
One way of using these constants is in initializing a static array that will 
serve as a jump table:

static void *array[] = { &&foo, &&bar, &&hack };

Then you can select a label with indexing, as in the following example.

goto *array[i];.
/*********************************/

üdv
Béla


----- Original Message ----- 
From: "Szima Gábor" <sygma at tesla.hu>
To: <elektro at tesla.hu>
Sent: Friday, July 28, 2006 12:09 PM
Subject: Re: C kérdés


>
> On Thu, 27 Jul 2006, Moczik Gabor wrote:
>
>> a goto-t felejtsd el, hacsak nincs valami igen nyomos ok, hogy miert kell 
>> az
>> oda.
>
> A goto nagyon hatekony tud lenni bizonyos esetekben, pl. hibakezelesnel.
>
> mem = malloc (...);
> if ( mem == NULL ) goto error;
> fd = fopen (...);
> if ( fd == NULL ) goto error;
> ...
>
> return true;
>
>
> error:
>
> if ( fd != NULL ) close (fd);
> if ( mem != NULL ) free (mem);
> ...
>
> return false;
>
>
>
>  -Sygma
>
> -----------------------------------------
>          elektro[-flame|-etc] 



More information about the Elektro mailing list