下面是我的程序。
void fun1(void);
int main(int argc, char *argv[])
{
cout<<"In main"<<endl;
atexit(fun1); //atexit calls the function at the end of main
cout<<"Exit main"<<endl;
return 0;
}
void fun1(void)
{
cout<<"fun1 executed"<<endl;
}
输出是
In main
Exit main
fun1 executed
但我打算这样的输出:
In main
fun1 executed
Exit main
我不想直接调用“fun1”函数或使用任何其他可以调用我的函数“fun1”的函数。
有什么办法可以实现这个输出吗?任何帮助都是最受欢迎的。