The goto Statement
The goto statement, bulwark of the older versions of BASIC and FORTRAN, is available in C. However, C, unlike those two languages, can get along quite well without it. Kernighan and Ritchie refer to the goto statement as “infinitely abusable” and suggest that it “be used sparingly, if at all.” First, we will show you how to use goto. Then, we will show why you usually don't need to.
The goto statement has two parts—the goto and a label name. The label is named following the same convention used in naming a variable, as in this example:
goto part2;
For the preceding statement to work, the function must contain another statement bearing the part2 label. This is done by beginning a statement with the label name followed by a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access