Skip to content

Instantly share code, notes, and snippets.

@jwu
Last active August 21, 2017 05:58
Show Gist options
  • Save jwu/918781 to your computer and use it in GitHub Desktop.
Save jwu/918781 to your computer and use it in GitHub Desktop.
a setjmp/longjmp example
#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