Full prototype:

_Noreturn void longjmp(jmp_buf, int);  

Purpose and Notes:

Returns the execution of the code and restores the enviornment to that which is saved by the jmp_buf variable passed in as the first argument. It also sets the return value of the setjmp call there to the second value passed in to the function or 1 if the second argument is null.

The function gives all control of the program from their to the setjmp macro location and the code continues from there.

Essentially a way to jump around the code base other than function calls and goto statements and can be in non-local scope.

It should be noted that this function is absolutly HATED and despised by many a programmers for the spaghetti code it can cause as well as the mental overhead of being able to jump to different spots in the code all willy nilly.


_Noreturn void- Doesn't return anything as the code will continue execution wherever the setjmp it takes you to is from.

Argument 1:

jmp_buf- The saved state by a call to set_jmp earlier in the code execution. The location and enviornment to go to.

Argument 2:

int- The value you want the destination setjmp macro to return.

Example 1