Last active
August 21, 2017 05:58
-
-
Save jwu/918781 to your computer and use it in GitHub Desktop.
a setjmp/longjmp example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <setjmp.h> | |
jmp_buf test1; | |
void tryjump () { | |
longjmp(test1, 3); | |
} | |
int main (void) { | |
if ( setjmp (test1) == 0 ) { | |
printf ("setjmp() returned 0."); | |
tryjump (); | |
} | |
else { | |
printf ("setjmp returned from a longjmp call."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment