Onega

a lot of VC++ posts, a few C# posts, and some miscellaneous stuff

Monday, May 07, 2007

warning about exit() function

The exit function, declared in the standard include file STDLIB.H, terminates a C++ program.
In MSDN:
Issuing a return statement from the main function is equivalent to calling the exit function with the return value as its argument.

That is NOT true.

When you call the exit or _exit functions, the destructors for any temporary or automatic objects that exist at the time of the call are not called.
While a return statement will call destructors of objects.

Labels:

0 Comments:

Post a Comment

<< Home