This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/setjmp.c

27 lines
432 B
C
Raw Permalink Normal View History

/* show LONGJMP, SETJMP */
#include <stdio.h>
#include <setjmp.h>
jmp_buf env;
void rtn()
{
printf( "about to longjmp\n" );
longjmp( env, 14 );
}
void main()
{
int ret_val;
ret_val = 293;
if( 0 == ( ret_val = setjmp( env ) ) ) {
printf( "after setjmp %d\n", ret_val );
rtn();
printf( "back from rtn %d\n", ret_val );
} else {
printf( "back from longjmp %d\n", ret_val );
}
}