Friday, April 9, 2010

Returning from main: exit vs return


Does it make a difference if the last statement in the main function is a "return" or an "exit"? I spent quite some time understanding the differences. However I am too lazy to consolidate all my findings and write my own notes here. So, here are the links that I found useful. Go through them in order and you will emerge with a good knowledge of the differences.

1. http://bytes.com/topic/c/answers/222362-difference-between-return-exit
2. http://bytes.com/topic/c/answers/221476-whats-difference-return-0-exit-0-exit-1-a
3. http://www.daniweb.com/forums/thread208168.html#
4. http://c-faq.com/ansi/exitvsreturn.html
5. http://c-faq.com/strangeprob/crashatexit.html
6. http://www.gnu.org/s/libc/manual/html_node/Cleanups-on-Exit.html
7. http://www.cplusplus.com/reference/clibrary/cstdlib/atexit/
8. http://stackoverflow.com/questions/461449/return-statement-vs-exit-in-main

Hope that helped :)

No comments:

Post a Comment