C examples for stdlib.h:atexit
function
<cstdlib> <stdlib.h>
Set function to be executed on exit
int atexit (void (*func)(void)) noexcept; int atexit (void (*func)(void));
Parameter | Description |
---|---|
function | Function to be called. The function should return no value and take no arguments. |
On success, a zero value is returned.
On error, a non-zero value is returned.
#include <stdio.h> #include <stdlib.h> void fnExit1 (void){ puts ("Exit function 1."); } void fnExit2 (void){ puts ("Exit function 2."); } int main ()/*w w w . j a va 2s. c o m*/ { atexit (fnExit1); atexit (fnExit2); puts ("Main function."); return 0; }