GeekInterview.com
  I am new, Sign me up!
 
Home C
 

Nonlocal Jump and Unconditional Jump

 
Category: C
Comments (0)


What is Nonlocal Jump and Unconditional Jump?


longjmp() and setjmp() functions implement a nonlocal jump of program execution. "longjmp" jumps to a program state previously recorded by "setjmp".


Both longjmp() and setjmp() functions must have the header file given below included.


#include <setjmp.h>


When your program calls setjmp(), the current state of the program is saved in a structure of type jmp_buf which is declared in <setjmp.h>.


Program can be restored to its original state by calling longjmp() function. This will restore the program to the state it was when the setjmp() was called.


goto is a unconditional branching statement used to transfer control of the program from one statement to another. This statement for branching must be within the same function for using goto. In other words it is not possible to implement goto between functions. In contrast the longjmp() and setjmp() functions need not be implemented in the same function.


Whatever may be the jump say goto or longjmp() generally it is good to avoid such jump conditions to have a good program.



Read Next: printf and sprintf



 
Related Topics


 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape