search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
39 views
asked Expert 11.4k points 14 22 28

1 Answer

0 votes
A goto statement implements a local jump of program execution, and the longjmp() and setjmp() functions implement a nonlocal, or far, jump of program execution.
Generally, a jump in execution of any kind should be avoided because it is not considered good programming practice to use such statements as goto and longjmp in your program.
A goto statement simply bypasses code in your program and jumps to a predefined position. To use the goto statement, you give it a labeled position to jump to. This predefined position must be within the same function. You cannot implement gotos between functions.
When your program calls setjmp(), the current state of your program is saved in a structure of type jmp_buf. Later, your program can call the longjmp() function to restore the program’s state as it was when you called setjmp().Unlike the goto statement, the longjmp() and setjmp() functions do not need to be implemented in the same function.
answered Guru 24.6k points 29 52 81

Related questions

0 votes
1 answer 44 views
44 views
asked rock Expert 15k points 15 23 30
0 votes
1 answer 29 views
0 votes
1 answer 29 views
29 views
asked rock Expert 15k points 15 23 30
0 votes
1 answer 22 views
22 views
asked sunny Expert 11.4k points 14 22 28
0 votes
1 answer 15 views
...