atexit : atexit « stdlib.h « C Tutorial






ItemValue
Header filestdlib.h
Declarationint atexit(void (*func)(void));
Functioncauses the function pointed to by func to be called upon normal program termination.
Returnreturns zero if the function is successfully registered as a termination function and nonzero otherwise.


At least 32 termination functions can be registered, and they will be called in the reverse order of their registration.

#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








23.3.atexit
23.3.1.atexit