文章目錄
當進程退出時會自動執行的函數,和析構函數很類似
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void test1()
{
printf ("hello test1\n");
}
void test2()
{
printf ("hello test2\n");
}
int main()
{
atexit(test1);
atexit(test2);
sleep(5);
printf ("hello main!\n");
exit(2);
return 0;
}
根據這裏改的
https://blog.csdn.net/u012206617/article/details/100123477
不過這裏有錯誤