HP C/iX Reference Manual (31506-90011)
Chapter 5 65
Expressions
Postfix Increment and Decrement Operators
Postfix Increment and Decrement Operators
The postfix increment operator ++ adds one to its operand after using its value. The postfix
decrement operator subtracts one from its operand after using its value.
Syntax
postfix-expression
postfix-expression
Description
You can only apply postfix increment ++ and postfix decrement operators to an operand
that is a modifiable lvalue with scalar type. The result of a postfix increment or a postfix
decrement operation is not an lvalue.
The postfix-expression is incremented or decremented after its value is used. The
expression evaluates to the value of the object before the increment or decrement, not the
object's new value.
If the value of X is 2, after the expression A=X is evaluated, A is 2 and X is 3.
Avoid using postfix operators on a single operand appearing more than once in an
expression. The result of the following example is unpredictable:
*p = *p;
The C language does not define which expression is evaluated first. The compiler can
choose to evaluate the left side of the = operator (saving the destination address) before
evaluating the right side. The result depends on the order of the subexpression evaluation.
Pointers are assumed to point into arrays. Incrementing (or decrementing) a pointer
causes the pointer to point to the next (or previous) element. This means, for example, that
incrementing a pointer to a structure causes the pointer to point to the next structure, not
the next byte within the structure. (Refer also to "Additive Operators" for information on
adding to pointers.)