IT Community - Software Programming, Web Development and Technical Support

longjmp() and setjmp()

This is a discussion on longjmp() and setjmp() within the C and C++ Programming forums, part of the Software Development category; Hui can i anybody tell me the difference between goto and longjmp() and setjmp()?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-27-2007, 04:50 AM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Exclamation longjmp() and setjmp()

Hui can i anybody tell me the difference between goto and longjmp() and setjmp()?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-27-2007, 05:19 AM
Senthilkumar Senthilkumar is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 93
Senthilkumar is on a distinguished road
Default Re: longjmp() and setjmp()

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>. If one want to restore the program to original state it can be done by called longjmp() function. This will restore the program to the state it was when the setjmp() was called.

The 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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-c-programming/2975-longjmp-setjmp.html
Posted By For Type Date
Programming This thread Refback 07-27-2007 05:32 AM


All times are GMT -7. The time now is 05:34 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0