📅  最后修改于: 2020-09-25 08:11:07             🧑  作者: Mango
longjmp() 函数在
void longjmp(jmp_buf env, int status);
要加载的环境存储在参数env中,该参数通过调用setjmp() 函数保存。
#include
#include
using namespace std;
int main()
{
jmp_buf env;
int val;
val = setjmp(env);
if (val==0)
{
cout << "setjmp returned " << val << endl;
longjmp(env,val);
}
else
{
cout << "setjmp returned " << val << endl;
cout << "Program terminating" << endl;
}
return 0;
}
运行该程序时,输出为:
setjmp returned 0
setjmp returned 1
Program terminating