5.0 Expressions 447
5.11 sizeofOperator
Given that
type is as described previously;
a is an expression;
then the expression
sizeof (type) has as its value the number of bytes needed to contain a value of
the specified type;
sizeof a has as its value the number of bytes required to hold the result
of the evaluation of a.
If typeis char, the result is defined to be 1. If ais the name of an array that has been
dimensioned (either explicitly or implicitly through initialization) and is not a formal
parameter or undimensioned externarray,sizeof agives the number of bytes required
to store the elements in a.
The type of integer produced by the sizeofoperator is size_t, which is defined in
the standard header file <stddef.h>.
If ais a variable-length array, the sizeofoperator is evaluated at runtime; otherwise a
is evaluated at compile time and the result can be used in constant expressions (see
Section 5.2).
5.12 Comma Operator
Given that
a, b are expressions;
then the expression
a, b causes ato be evaluated and then bto be evaluated; the type and value
of the expression is that of b.
5.13 Basic Operations with Arrays
Given that
a is declared as an array of nelements;
i is an expression of any integer data type;
v is an expression;
then the expression
a[0] references the first element of a;
a[n - 1] references the last element of a;
a[i] references element number iof a;
a[i] = v stores the value of vinto a[i].
20 0672326663 AppA 6/10/04 2:01 PM Page 447