If more than one atexit function has been specified by different calls to this function, they are all executed in reverse order as a stack, i.e. the last function specified is the first to be executed at exit.
One single function can be registered to be executed at exit more than once.
C++ implementations are required to support the registration of at least 32 atexit functions.
Parameters
- function
- Function to be called. The function has to return no value and accept no arguments.
Return Value
A zero value is returned if the function was successfully registered, or a non-zero value if it failed.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Output:
Main function. Exit function 2. Exit function 1. |
See also
| exit | Terminate calling process (function) |
| abort | Abort current process (function) |
