首页 > 其他分享 >在main函数执行完后,再执行其他方法

在main函数执行完后,再执行其他方法

时间:2022-11-13 11:34:23浏览次数:40  
标签:main fn2 fn1 atexit 完后 void int printf 执行

 

方法如下:

 1 #include <stdio.h>
 2 
 3 int atexit(void(*function)(void));
 4 void fn1(void), fn2(void);
 5 
 6 int main(int argc, char **argv) {
 7     printf("Hello, World!\n");
 8     atexit(fn1);
 9     atexit(fn2);
10     return 0;
11     
12 }
13 
14 void fn1()
15 {
16     printf("come this\n");
17 }
18 void fn2()
19 {
20     printf("come this 2\n");
21 }

执行结果:

Hello, World!
come this 2
come this

 

标签:main,fn2,fn1,atexit,完后,void,int,printf,执行
From: https://www.cnblogs.com/xhu218/p/16885653.html

相关文章