Definition | #include <stdlib.h> int atexit(void (*funct) (void));
| ||
Return val. | 0
| on successful registration of the function. on error. | |
Notes | Up to 40 functions can be registered. The functions are called in the reverse order of their The functions registered with
Only when all the termination routines have been processed are any files still open |
Example | The termination routines end1 and end2 are registered with #include <stdlib.h> #include <stdio.h> void end1(void); void end2(void); int main(void) { atexit(end1); atexit(end2); printf("main function\n"); return 0; } void end1(void) { printf("end1 routine\n"); } void end2(void) { printf("end2 routine\n"); } |
See also | exit, raise, signal |