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/longjmp.c

23 lines
390 B
C
Raw Normal View History

#include <stdio.h>
#include <setjmp.h>
jmp_buf env;
void rtn()
{
printf( "about to longjmp\n" );
longjmp( env, 14 );
}
void main()
{
int 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 );
}
}