[LCP]Why do I do this? or exit() vs. return

Greg Black gjb at gbch.net
Thu Jul 10 12:29:01 UTC 2003


On 2003-07-10, bruceb3 at zip.com.au wrote:

> I would stick to using exit because at some
> latter point the programmers may start using
> atexit and on_exit, and if this happens you 
> won't have to modify the code.

You guys might want to read the description of atexit() and
return from main() in the C standard.

Since main() is defined as a function returning int, you should
always use a return statement (preferably with one of the macros
provided by the standard as its argument).

And yes, this is one of those style questions and there are many
correct answers.

-- 
Greg Black <gjb at gbch.net> <http://www.gbch.net/gjb.html>
GPG signed mail preferred; further information in headers.



More information about the linuxCprogramming mailing list