atexit() एक ऐसा फ़ंक्शन है जो उपयोगकर्ता को एक फ़ंक्शन पंजीकृत करने की अनुमति देता है जिसे प्रोग्राम समाप्ति के आधार पर कॉल करना होता है।
यह एक पूर्वनिर्धारित फ़ंक्शन है जो stdlib शीर्षलेख फ़ाइलों में शामिल है।
उदाहरण 1
#include<stdio.h>
#include<stdlib.h>
void welcome(void){
printf("Welcome to New,");
}
void world(void){
printf("World\n");
}
int main(){
//test atexit ,call user defined function
atexit(world);
atexit(welcome);
return 0;
} आउटपुट
Welcome to New,World
उदाहरण 2
#include<stdio.h>
#include<stdlib.h>
void first(void){
printf("This is a beautiful,");
}
void second(void){
printf("Wonderful life\n");
}
int main(){
//test atexit ,call user defined function
atexit(second);
atexit(first);
return 0;
} आउटपुट
This is a beautiful,Wonderful life