Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) goto

 

goto is a keyword to jump to a label. Prefer not to use goto, it is known to produce spagetti code.

 

#include <iostream>

int main()
{
  std::cout << "Beginning\n";
  goto label1;
  std::cout << "Unreachable\n";
  label1:
  std::cout << "Ending\n";
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict