首页 > 编程语言 > 详细

C++中设置Main函数结束后执行的代码_艾孜尔江撰

时间:2021-06-13 01:09:59      阅读:30      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <cstdlib>
using namespace std;


int func1(),func2(),func3();

int main(int argc,char * argv[])
{
	_onexit(func2); //函数注册时入栈,调用时出栈 
	_onexit(func1);                   
	_onexit(func3);
	cout<<"First Line"<<endl;
	cout<<"Second Line"<<endl;
}

int func1()
{
	cout<<"fun1() is executed!"<<endl;
	return 0;
}

int func2()
{
	cout<<"fun2() is executed!"<<endl;
	return 0;
}
int func3()
{
	cout<<"fun3() is executed!"<<endl;
	return 0;
}



效果
技术分享图片

C++中设置Main函数结束后执行的代码_艾孜尔江撰

原文:https://www.cnblogs.com/ezhar/p/14879015.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!