17 Miscellaneous and Advanced Features
THIS CHAPTER DISCUSSES SOME MISCELLANEOUS FEATURESof the C language that have
not yet been covered and provides a discussion of some more advanced topics, such as
command-line arguments and dynamic memory allocation.
Miscellaneous Language Statements
This section discusses two statement you haven’t encountered to this point: the gotoand
the nullstatement.
The gotoStatement
Anyone who has learned about structured programming knows of the bad reputation
afforded to the gotostatement.Virtually every computer language has such a statement.
Execution of a gotostatement causes a direct branch to be made to a specified point
in the program.This branch is made immediately and unconditionally upon execution of
the goto.To identify where in the program the branch is to be made, a labelis needed. A
label is a name that is formed with the same rules as variable names and must be imme-
diately followed by a colon.The label is placed directly before the statement to which
the branch is to be made and must appear in the same function as the goto.
So, for example, the statement
goto out_of_data;
causes the program to branch immediately to the statement that is preceded by the label
out_of_data:.This label can be located anywhere in the function, before or after the
goto, and might be used as shown:
out_of_data: printf ("Unexpected end of data.\n");
...