main 主函数执行完毕后,是否可能会再执行一段代码,给出说明
答案:可以,可以用_onexit 注册一个函数,它会在main 之后执行int fn1(void), fn2(void), fn3(void), fn4 (void);
void main( void )
{
String str(“zhanglin”);
_onexit( fn1 );
_onexit( fn2 );
_onexit( fn3 );
_onexit( fn4 );
printf( “This is executed first. ” );
}
int fn1()
{
printf( “next. ” );
return 0;
}
int fn2()
{
printf( “executed ” );
return 0;
}
int fn3()
{
printf( “is ” );
return 0;
}
int fn4()
{
printf( “This ” );
return 0;
}
The _onexit function is passed the address of a function (func) to be called when the program terminates normally. Successive calls to _onexit create a register of functions that are executed in LIFO (last-in-first-out) order. The functions passed to _onexit cannot take parameters.
void main( void )
{
String str(“zhanglin”);
_onexit( fn1 );
_onexit( fn2 );
_onexit( fn3 );
_onexit( fn4 );
printf( “This is executed first. ” );
}
int fn1()
{
printf( “next. ” );
return 0;
}
int fn2()
{
printf( “executed ” );
return 0;
}
int fn3()
{
printf( “is ” );
return 0;
}
int fn4()
{
printf( “This ” );
return 0;
}
The _onexit function is passed the address of a function (func) to be called when the program terminates normally. Successive calls to _onexit create a register of functions that are executed in LIFO (last-in-first-out) order. The functions passed to _onexit cannot take parameters.
【main 主函数执行完毕后,是否可能会再执行一段代码,给出说明】相关文章
1. main 主函数执行完毕后,是否可能会再执行一段代码,给出说明
3. swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上
4. swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上?
8. 编写一个 C 函数,该函数在一个字符串中找到可能的最长的子字符串,且该字符串是由同一字符组成的
10. 这段代码难道不该打印出56吗
本文来源:https://www.mianshiwenti.com/a13219.html
进入下载页面
上一篇:写一个方法1000的阶乘
下一篇:在C语言中"指针和数组等价"到底是什么意思?
﹝main 主函数执行完毕后,是否可能会再执行一段代码,给出说明﹞相关内容
- 请写出一段Python代码实现删除一个list里面的重复元素
- PHP如何去执行一个SQL语句
- 如何执行一个shell程序
- 编写类String 的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 介绍一下Prototype的$()函数,$F()函数,$A()函数都是什么作用?
- 如果你被录用,是否马上就可来上班?
- 深圳用人单位是否可以扣押劳动者身份证吗?
- 你是否可以接受加班?
- 局部内部类是否可以访问非final变量?