help for using setjmp and longjmp functions
Hi,
I tried writing a simple program to findout usage of setjmp andlongjmp() functions. The program ran in an infinite loop showing some warnings. What is the problem? Can someone help me depicting the behaviour of the setjmp and longjmp functions
/******** beginning of code *************/
#include <setjmp.h>jmp_buf jmpbuffer;
void bar(void)
{
printf("inside bar\n");
longjmp(jmpbuffer, 1);
}void foo(void)
{
printf("before calling bar()\n");
bar();
printf("after calling bar()\n");
}
int
main(void)
{
printf("before calling foo()\n");
if(setjmp(jmpbuffer)!=0)
perror("error setting");
foo();
printf("after foo()\n");
return 0;
}/**************** end of code ***********/
Hoping for help
TIA..
Signature · 3 lines
With regards, Jagadeesh Bhaskar P