1.

Which is the true statement with respect to the function longjmp()?(a) the function where setjmp() was called has terminated, then the results are undefined(b) the function where setjmp() was called has terminated, then the results are defined(c) the function where jmp_buf was called has terminated, then the results are undefined(d) the function where jmp_buf was called has terminated, then the results are definedI got this question by my school principal while I was bunking the class.My question comes from Non-Local Jumps topic in chapter C Library of C

Answer»

Right answer is (a) the function where setjmp() was called has terminated, then the results are undefined

Easy EXPLANATION - The longjmp() function restores the environment saved by the most recent invocation of the SET jmp MACRO in the same invocation of the program, with the CORRESPONDING jmp buf ARGUMENT. The behavior is undefined, if there has been no such invocation, or if the function containing the invocation of the setjmp() macro has terminated execution in the interim.



Discussion

No Comment Found

Related InterviewSolutions