| Increment operator ('++')

Previous | Unary operators | Next

The increment operator may be used as a postincrement or preincrement operator:

    expr ++           (postincrement)
    ++ expr           (preincrement)

The expression is called the operand; it must be of scalar type (arithmetic or pointer types) and must be a modifiable lvalue.
When postincrement operator form is used, the value of the whole expression is the value of the postfix expression before the increment is applied. After the postfix expression is evaluated, the operand is incremented by 1.
When preincrement operator form is used, the operand is incremented by 1 before the expression is evaluated; the value of the whole expression is the incremented value of the operand.
The increment value is appropriate to the type of the operand. Pointer types follow the rules for pointer arithmetic. In other words, the actual address on which a pointer points to is incremented by the size of the pointed object (not by 1, except if the pointed object is one byte long), so after the incrementing, the pointer points to the next object in a sequence (e.g. to a next element in an array, etc.).
Note: GNU C extends the pointer arithmetic to be valid even on void pointers and pointers to functions (see extended pointer arithmetic for more info).