C kérdés

Szima Gábor sygma at tesla.hu
Fri Jul 28 12:09:14 CEST 2006


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



More information about the Elektro mailing list