Antonio Parolini wrote:
>What is the difference between:
main(......) {
exit(0);
}
and
main(......) {
return(0);
}
Anant wrote:
If you are calling some function recursively then return 0 will just go
to one level down on the stack, while exit 0 will terminate this
thread.
Note: Top posting corrected.
Per 3.6.1/3: "The function main shall not be used (3.2) within a
program." Per 3.2/2, this indicates that you cannot call main
recursively. So Anant's comment is irrelevant. Plus, the C++ standard
says nothing about threads.
Per 3.6.1/4 exit will terminate the program without destroying any
objects with automatic storage duration. Rolf noted this in response to
Andre's comment.
Thus, the difference between Antonio's two examples is mainly the
destruction of any automatic variables in main().