HP C A.06.05 Reference Manual

Expressions and Operators
Evaluation of Expressions
Chapter 5 145
static char a_char, c[20] = {"Valerie"}, *pc = c;
while (a_char = *pc++) {
. . .
This while statement uses C's ability to both assign and test a value. Every iteration of while
assigns a new value to variable a_char. The byproduct of an assignment is equal to the value
that gets assigned. The byproduct value will remain nonzero until the end of the string is
reached. When that happens, the byproduct value will become 0 (false), and the while loop
will end.
Evaluation Order of Subexpressions
The C language does not define the evaluation order of subexpressions within a larger
expression except in the special cases of the &&, ||, ?:, and , operators. When programming
in other computer languages, this may not be a concern. C's rich operator set, however,
introduces operations that produce side effects. The ++ operator is a prime example. The ++
operator increments a value by 1 and provides the value for further calculations. For this
reason, expressions such as
b = ++a*2 + ++a*4;
are dangerous. The language does not specify whether the variable a is first incremented and
multiplied by 4 or is first incremented and multiplied by 2. The value of this expression is
undefined.