How can I use goto function across different functions .For ex ,
main()
{
....
REACH:
......
}
void function()
{
goto REACH ;
}
How to implement such usage ?
How can I use goto function across different functions .For ex ,
main()
{
....
REACH:
......
}
void function()
{
goto REACH ;
}
How to implement such usage ?
You can't in Standard C++. From $6.6.4/1 of the C++ Language Standard
...or in Standard C. From $6.8.6.1/1 of the C Language Standard
You can't in Standard C; labels are local to a single function.
The nearest standard equivalent is the
setjmp()
andlongjmp()
pair of functions.GCC has extensions to support labels more generally.
For gcc:
Note that this can be an undefined behavior