atexit() হলো একটি ফাংশন যা ব্যবহারকারীকে একটি ফাংশন রেজিস্টার করতে দেয় যা প্রোগ্রাম টার্মিনেশনের সময় কল হবে।
এটি একটি প্রিডিফাইনড ফাংশন যা stdlib হেডার ফাইলে থাকে।
উদাহরণ ১
#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
উদাহরণ ২
#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