Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Write a C program to check the atexit() function
The atexit() is a function that allows the user to register a function that has to be called based on program termination.
It is a predefined function that is included in stdlib header files.
Example 1
#include<stdio.h>
#include<stdlib.h>
void welcome(void){
printf("Welcome to New,");
}
void world(void){
printf("World
");
}
int main(){
//test atexit ,call user defined function
atexit(world);
atexit(welcome);
return 0;
}
Output
Welcome to New,World
Example 2
#include<stdio.h>
#include<stdlib.h>
void first(void){
printf("This is a beautiful,");
}
void second(void){
printf("Wonderful life
");
}
int main(){
//test atexit ,call user defined function
atexit(second);
atexit(first);
return 0;
}
Output
This is a beautiful,Wonderful life
Advertisements
