Atexit() - C library function Program

Declaration :

int atexit(void (*func)(void))

Explanation :

PurposeThe C library function int atexit(void (*func)(void)) causes the specified function func to be called when the program terminates. You can register your termination function anywhere you like but it will be called at the time of program termination.
Parameters func ===> This is the function to be called at the termination of the program.
Return ValueThis function returns a zero value if the function is registered successfully otherwise a non-zero value if it is failed.
Exception

C Program : Example

The following example shows the usage of atexit() function.

#include 
#include 
void functionA ()
{
   printf("This is functionA\n");
}
int main ()
{
   /* register the termination function */
   atexit(functionA );
   printf("Starting  main program...\n");
   printf("Exiting main program...\n");
   return(0);
}