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, कॉल यूजर डिफाइंड फंक्शन
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, कॉल यूजर डिफाइंड फंक्शन
atexit(second);
atexit(first);
return 0;
}
आउटपुट
This is a beautiful,Wonderful life