CHAPTER2-31.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER2-31.cpp
- #include <setjmp.h>
- #include <stdio.h>
- jmp_buf j;
- void raise_exception(void)
- {
- printf("exception raisedn");
- longjmp(j, 1); /* jump to exception handler */
- printf("this line should never appearn");
- }
- int main(void)
- {
- if (setjmp(j) == 0){ printf("'setjmp' is initializing 'j'n"); raise_exception();//Restore context
- printf("this line should never appearn"); }
- else { printf("'setjmp' was just jumped inton"); /* this code is the exception handler */ }
- return 0;
- }