[cs631apue] exit() vs return in c programs
sakhter at stevens.edu
Wed Sep 10 15:57:47 EDT 2014
I know it matters when exit() is called from any method other than main(). But I noticed that in the text book they always use exit() even in the main() function. That's why I was curious. I guess its more like common practice then.
On Sep 10, 2014, at 3:50 PM, JIANLONG ZHOU <jzhou14 at stevens.edu> wrote:
> Hi, I think there is no difference when you use exit(0) or return 0 in main(), but different when you try to use in sub function. Simply return will exit from current function, but exit will terminate the program, here is the link you can look at:
> JIANLONG ZHOU
> On Sep 10, 2014, at 3:32 PM, Sadia Akhter <sakhter at stevens.edu> wrote:
>> In my previous experience with C, I have always used "return 0;" to return from main() function. Those were of course not any system programming codes. However, in the text book APUE, I noticed that they always use "exit(0)" in main(). Can anyone tell me why is that? Is there any significant difference between these two? Or is it just regular practice?
>> Sadia Akhter
>> cs631apue mailing list
>> cs631apue at lists.stevens.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cs631apue