Terminates the program with normal cleanup actions.
The function exit() has additional behavior in the following order:
- Objects with static storage duration are destroyed and functions registered by calling atexit are called.
- Objects with static storage duration are destroyed in the reverse order of construction. If the main() function contains no automatic objects control can be transferred to main() if an exception thrown is caught in main().
- Functions registered with atexit are called
- All open C streams with unwritten buffered data are flushed, closed, including streams associated with cin and cout. All tmpfile() files are removed.
- Control is returned to the host environment.
If status is zero or EXIT_SUCCESS, a successful termination is returned to the host environment.
If status is EXIT_FAILURE, an unsuccessful termination is returned to the host environment.
Otherwise the status returned to the host environment is implementation-defined.