#include #include jmp_buf buf; void function1(int x) { printf("Function1 called, x = %d.\n", x); if(setjmp(buf) == 0) { printf("We just set the jump.\n"); } else { printf("We just jumped here from longjmp (x = %d)!\n", x); } printf("Function1 returning.\n"); } void function2() { /* go to the setjmp location and pass a 1 */ printf("Jumping!\n"); longjmp(buf, 1); } int main() { printf("Main starting.\n"); function1(10); function2(); printf("Main ending.\n"); return 0; }