Is exit status truly equivalent to returning the same status from main?

Q

Is exit status truly equivalent to returning the same status from main?

✍: Guest

A

Yes and no. The Standard says that a return from the initial call to main is equivalent to calling exit. However, a return from main cannot be expected to work if data local to main might be needed during cleanup;A few very old, nonconforming systems may once have had problems with one or the other form. (Finally, the two forms are obviously not equivalent in a recursive call to main.)

2015-12-16, 684👍, 0💬