is there anything wrong with return(n) from main?

Doug Gwyn gwyn at brl-smoke.ARPA
Sat Jul 2 04:50:14 AEST 1988


In article <741 at vsi.UUCP> friedl at vsi.UUCP (Stephen J. Friedl) writes:
>doing a return(n) from main: I used exit(n) instead.

"return n" is technically correct, and is slightly more satisfactory
from a "top-down control" viewpoint.  I have heard that there are
some purported C implementations that ignore the return value
from main(), though, always returning a success indicator unless
exit() is used.  Those aren't Standard-conforming implementations,
but you might be stuck with one.

P.S.  You don't need parentheses around the return expression.



More information about the Comp.lang.c mailing list