摘要: 原理: 使用 _onexit() 函数注册一个函数,这个函数会在main函数退出后执行使用原则: 1、包含在cstdlib中,是c语言中的库函数; 2、需要注册的函数格式为:int类型返回值、无参数,参见_onexit()定义; 3、无论_onexit函数放到main中哪个位置,相应的已注册函数都是最后执行; 4、如果用_onexit注册了多个函数,则已注册函数的执行顺序跟注册顺序相反;测试代码: 1 #include "stdafx.h" 2 #include 3 #include 4 5 using namespace std; 6 7 8 int test1( int 阅读全文
posted @ 2014-02-18 14:29 weiquxiong 阅读(162) 评论(0) 推荐(0)