Rookie Engineer

If you aren't the kind of person that feels this way naturally, you'll need to become one in order to make it as a hacker. Otherwise you'll find your hacking energy is sapped by distractions like sex, money, and social approval.

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  24 Posts :: 0 Stories :: 2 Comments :: 0 Trackbacks

常用链接

留言簿

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

函数名: atexit
  头文件:#include<stdlib.h>
  功 能: 注册终止函数(即main执行结束后调用的函数)
  用 法: int atexit(void (*func)(void));
  注意:按照ISO C的规定,一个进程可以登记多达32个函数,这些函数将由exit自动调用。atexit()注册的函数类型应为不接受任何参数的void函数,exit调用这些注册函数的顺序与它们 登记时候的顺序相反。同一个函数如若登记多次,则也会被调用多次。

#include "iostream"
using namespace std;

void func1()
{
   cout<<"func1()"<<endl;
}

void func2()
{
   cout<<"func2()"<<endl;
}

void main()
{
   atexit(func1);
   atexit(func2);
   cout<<"main fun exit"<<endl;
}

输出:
main fun exit
func2()
func1()
posted on 2012-08-21 00:46 micwu 阅读(344) 评论(0)  编辑 收藏 引用 所属分类: C++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理