Programming in C

(Barry) #1
456 Appendix A C Language Summary

Functions that take a variable number of arguments must be declared as such.
Otherwise, the compiler is at liberty to assume the function takes a fixed number of
arguments based upon the number actually used in the call.
A function whose return type is declared asvoidcauses the compiler to flag any calls
to that function that try to make use of a returned value.
All arguments to a function are passed by value; therefore, their values cannot be
changed by the function. If a pointer is passed to a function, the function canchange val-
ues referenced by the pointer, but it still cannot change the value of the pointer variable
itself.

7.3 Function Pointers


A function name, without a following set of parentheses, produces a pointer to that
function.The address operator can also be applied to a function name to produce a
pointer to it.
If fpis a pointer to a function, the corresponding function can be called either by
writing
fp ()
or
(*fp) ()
If the function takes arguments, they can be listed inside the parentheses.

8.0 Statements


A program statement is any valid expression (usually an assignment or function call) that
is immediately followed by a semicolon, or it is one of the special statements described
in the following sections. A labelcan optionally precede any statement, and consists of an
identifier followed immediately by a colon (see Section 8.6).

8.1 Compound Statements


Program statements that are contained within a pair of braces are known collectively as a
compoundstatement or blockand can appear anywhere in the program that a single state-
ment is permitted. A block can have its own set of variable declarations, which override
any similarly named variables defined outside the block.The scope of such local variables
is the block in which they are defined.

8.2 The breakStatement


The general format for declaring a breakstatement is as follows:
break;

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

Free download pdf