goto statement

   
goto statement Transfers execution to a labeled statement

  statement  := goto  identifier  ; 

The goto statement transfers control to another statement in the same function. The identifier must match a statement label elsewhere in the function. Statement labels have the form identifier : statement .

Control cannot transfer into a try block. Transferring control into the middle of a block and across a declaration results in undefined behavior unless the declaration is for an uninitialized POD object.

Example

 while (getline(cin, line))   for (size_t i = 0; i < line.size(  ); ++i)     if (line[i] == '.')  goto  exit; // Break out of nested loops. exit: ... 

See Also

break , continue , statement , Chapter 4

   


C++ in a Nutshell
C++ in a Nutshell
ISBN: 059600298X
EAN: 2147483647
Year: 2005
Pages: 270
Authors: Ray Lischner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net