add setjmp
This commit is contained in:
parent
944e0b9f85
commit
fc76ba1cf6
|
@ -0,0 +1,23 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
jmp_buf buf;
|
||||||
|
|
||||||
|
|
||||||
|
void banana(void)
|
||||||
|
{
|
||||||
|
printf("in banana() \n");
|
||||||
|
longjmp(buf, 1);
|
||||||
|
/* 一下代码不会被执行 */
|
||||||
|
printf("you'll never see this, because i longjmp'd");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
if (setjmp(buf)){
|
||||||
|
printf("back in main \n");
|
||||||
|
}else{
|
||||||
|
printf("first time throught\n");
|
||||||
|
banana();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue