fwee wrote:
What is the difference between using exit(n) and return n in main(), if
any? I know that exit(n) is a function that exits and return n exits via a
return value, but is there any reason to specify one rather than the
other? Thanks!
Exit exit the program with n status no matter how deeply you've recursed
in functions.
Example:
int blah (void)
{
return 1;
/* exit(1) would actually exit the program here, whereas return
does not */
}
int main (void)
{
blah();
return 0;
/* exit(0) and return have pretty much the same function in this
context */
}