main主函數執行完後,可以利用atexit再執行一段代碼

#include<stdlib.h>
#include<stdio.h>

int atexit(void(*function)(void));

void fun1(void),fun2(void),fun3(void);

int main(){
 printf("begin/n");
 atexit(fun1);
 atexit(fun2);
 atexit(fun3);
 printf("over/n");
 return 0;
}

void fun1()
{
 printf("first./n");
}
void fun2()
{
 printf("second/n");
}
void fun3()
{
 printf("third/n");
}

 

運行結果:

begin
over
third
second
first.
Press any key to continue

發佈了30 篇原創文章 · 獲贊 2 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章