📄 chapter2-31.cpp
字号:
//文件名:CHAPTER2-31.cpp
#include <setjmp.h>
#include <stdio.h>
jmp_buf j;
void raise_exception(void)
{
printf("exception raised\n");
longjmp(j, 1); /* jump to exception handler */
printf("this line should never appear\n");
}
int main(void)
{
if (setjmp(j) == 0){ printf("'setjmp' is initializing 'j'\n"); raise_exception();//Restore context
printf("this line should never appear\n"); }
else { printf("'setjmp' was just jumped into\n"); /* this code is the exception handler */ }
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -