longjmp - C setjmp.h

C examples for setjmp.h:longjmp

Type

function

From

<setjmp.h>
<csetjmp>

Description

Long jump

Prototype

void longjmp (jmp_buf env, int val);

Description

Restores the environment to the state indicated by env, evaluating the setjmp expression that filled env as val.

Parameters

ParameterDescription
env jumping point to restore
val Value to which the setjmp expression evaluates. If this is zero, the expression evaluates as 1.

Return value

none.

Demo Code


#include <stdio.h>
#include <setjmp.h>

int main()// w  w  w  . ja v a 2 s  . co  m
{
  jmp_buf env;
  int val;

  val=setjmp(env);

  printf ("val is %d\n",val);

  if (!val) 
     longjmp(env, 1);

  return 0;
}

Related Tutorials