[cs631apue] exit() vs return in c programs

JIANLONG ZHOU jzhou14 at stevens.edu
Wed Sep 10 15:50:25 EDT 2014


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: 
http://stackoverflow.com/questions/17383015/difference-between-return-0-and-exit-0

Thanks,
JIANLONG ZHOU
On Sep 10, 2014, at 3:32 PM, Sadia Akhter <sakhter at stevens.edu> wrote:

> Hi,
> 
> 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?
> 
> Thanks,
> Sadia Akhter
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20140910/f07a1773/attachment.html>


More information about the cs631apue mailing list