C/stdlib.h/atexit
atexit: causes the function pointed to by func to be called upon normal program termination
<source lang="cpp">
//Declaration: int atexit(void (*func)(void)); //Return: returns zero if the function is successfully registered as a termination function and nonzero otherwise.
#include <stdlib.h> #include <stdio.h> void done(void); int main(void) { if(atexit(done)){ printf("Error in atexit()."); } return 0; } void done(void) { printf("Hello There"); }
/* Hello There*/
</source>