Run the coding after exiting main function

Do you think that it is possible to run the code after exiting main function? Yes ,it is possible to run the codes after exiting main function also.

Consider this Simple Program:
#includ<stdio.h>
#include<stdlib.h>
void after_main()
{

printf("\nThis will run while exiting the main function");
}
int main()
{
atexit(after_main);
printf("This is the Main end");
return 0;
}

This will results in
This is the Main end
This will run while exiting the main function

atexit(function_name):

This function call the function which is specified after exiting the main function. It is defined in stdlib header file.

Related Posts