main() [exit vs. return]

Adam Stoller ghoti+ at andrew.cmu.edu
Sat Jul 7 07:15:50 AEST 1990


Excerpts from netnews.comp.lang.c: 6-Jul-90 Re: main() arguments, was
R.. Stephen Clamage at taumet.c (965)

> "A return from the initial call to the _main_ function is equivalent to
> calling the _exit_ function with the value returned by the _main_
function as its argument."


If one uses exit()  [with argument EXIT_SUCCESS (?)] - I believe ANSI
specifies that any functions that were registered via the atexit()
function should be called prior to the final termination of the program.

If one uses return from main() do the functions registered with atexit()
get called ? (i.e. just how equivelent are they?)

--fish
[return(exit(0));]



More information about the Comp.lang.c mailing list