Mega Code Archive

 
Categories / C / Code Snippets
 

Memory long jump

#include <setjmp.h> #include <stdio.h> jmp_buf ebuf; void f(void); int main(void) { int j; printf("1 "); j = setjmp(ebuf); if(j == 0) { f(); printf("This will not be printed."); } printf("%d", j); return 0; } void f(void) { printf("2 "); longjmp( ebuf, 3); }