1
#include <stdio.h>

void Check (short);

int main()
{
    short a;`

    //[... code ...]

    List :

    //[... code ...]

    Check (a);

    //[... code ...]
}

void Check (short a);
{
    if (a == 1)
    {
        goto List;
    }
}

How to implement such usage ?

ex main

  • I want to go to list

    - function jump to main

  • yas

  • i am a beginner

  1. Please answer me
black hole
  • 39
  • 4
  • 1
    1) you can't. 2) Don't even think about it! 3) Spaghetti belong on a plate with sauce, not in program code! 4) You might want to start an Apple ][ or VIC64 emulator and program them in BASIC. Thoses dialects from the 70ies indeed needed `goto`. – too honest for this site Feb 24 '17 at 20:18
  • alternative to "goto" – black hole Feb 24 '17 at 20:20
  • Learn the language and how to program. There are book for it ... – too honest for this site Feb 24 '17 at 20:21
  • 1
    @blackhole: [setjmp and longjmp](http://man7.org/linux/man-pages/man3/setjmp.3.html) allow you to perform non-local gotos, but they are a *pain* in the ass to use correctly. You really, really, *really* **do not** want to do this. – John Bode Feb 24 '17 at 20:37

1 Answers1

2

It is not possible in C.

C standard says,

The identifier in a goto statement shall name a label located somewhere in the enclosing function. A goto statement shall not jump from outside the scope of an identifier having a variably modified type to inside the scope of that identifier.

msc
  • 33,420
  • 29
  • 119
  • 214