atexit

The atexit function registers functions to be called when exit is called in normal program termination.

  extern "C" int atexit(void (* f)(void))

  extern "C++" int atexit(void (* f)(void)) 
Remarks

If there is no handler for a thrown exception terminate is called. The registration of at least 32 functions is allowed.

The atexit() function returns zero if the registration succeeds, non zero if it fails.