Header file:
setjmp.h
Synopsis:
int setjmp(jmp_buf env);
void longjmp(jmp_buf env, int val);
Description:
setjmp | It saves the stack environment in env for use by longjmp. And the stack environment gets invalidated if the function calling setjmp returns. |
longjmp | It restores the state saved by the most recent call of setjmp or it makes our program execution shift to the last call of setjmp. |
Sample program for setjmp and longjmp:
#include<stdio.h>
#include<setjmp.h>
int main() {
jmp_buf env;
int flag = 0;
if(setjmp(env) == 0) {
printf("setjmp called directly\n");
} else {
printf("Hit due to the call of longjmp\n");
flag = 1;
}
if(!flag)
longjmp(env,4);
printf("End of code\n");
return 0;
}
#include<setjmp.h>
int main() {
jmp_buf env;
int flag = 0;
if(setjmp(env) == 0) {
printf("setjmp called directly\n");
} else {
printf("Hit due to the call of longjmp\n");
flag = 1;
}
if(!flag)
longjmp(env,4);
printf("End of code\n");
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/setjmp$ ./a.out
setjmp called directly
Hit due to the call of longjmp
End of code
setjmp called directly
Hit due to the call of longjmp
End of code
It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
ReplyDeleteData Science Interview Questions
Angular JS Interview Questions
Big Data Training in Velachery
AWS Certified Developer
Best Resource of Learning Devops
Blueprism Interview Questions
Automation Anywhere Interview Questions
Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks
ReplyDelete