fork download
  1. #include <setjmp.h>
  2. #include <stdio.h>
  3.  
  4. jmp_buf x;
  5.  
  6. void f()
  7. {
  8. longjmp(x,5);
  9. }
  10.  
  11. int main()
  12. {
  13. int i = 0;
  14.  
  15. if ((i = setjmp(x)) == 0)
  16. {
  17. f();
  18. }
  19. else
  20. {
  21. switch(i)
  22. {
  23. case 1: /* ... */ break;
  24. case 2: /* ... */ break;
  25. default: fprintf(stdout, "error code = %d\n", i); break;
  26. }
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
error code = 5