Programming in C

(Barry) #1
458 Appendix A C Language Summary

8.6 The gotoStatement


The general format for declaring the gotostatement is as follows:
goto identifier;
Execution of the gotocauses control to be sent directly to the statement labeled
identifier.The labeled statement must be located in the same function as the goto.

8.7 The ifStatement


One general format for declaring an ifstatement is as follows:
if ( expression)
programStatement
If the result of evaluating expressionis nonzero,programStatementis executed; other-
wise, it is skipped.
Another general format for declaring an ifstatement is as follows:
if ( expression)
programStatement_1
else
programStatement_2
If the value of expressionis nonzero, the programStatement_1is executed; otherwise,
programStatement_2is executed. If programStatement_2is another ifstatement, an
if-else ifchain is affected:
if ( expression_1)
programStatement_1
else if ( expression_2)
programStatement_2

else
programStatement_n
An elseclause is always associated with the last ifstatement that does not contain an
else. Braces can be used to change this association if necessary.

8.8 The nullStatement


The general format for declaring the nullstatement is as follows:
;
Execution of a null statement has no effect and is used primarily to satisfy the require-
ment of a program statement in a for,do, or whileloop. For example, in the following
statement, which copies a character string pointed to by fromto one pointed to by to:
while ( *to++ = *from++ )
;

20 0672326663 AppA 6/10/04 2:01 PM Page 458

Free download pdf