You are here

goto

6 February, 2015 - 16:33

The goto structure is not allowed in good structured programming. It is with a certain amount of hesitancy that we even show it. Many textbooks do not cover the goto. Within the C++ programming language you create a label with an identifier name followed by a colon. You use the command word goto followed by the label. A label can be used before it is declared.

Example 12.9: C++ source code

some lines of code;
goto mynewspot;               //jumps to the label
some lines of code;
some lines of code;
some lines of code;
mynewspot: some statement;    //Declared label
some lines of code;