Skip to main content
The -- (decrement) operator is a unary arithmetic operator that decreases the value of its operand by one. It requires a modifiable lvalue of a scalar type (integer, floating-point, or pointer) as its operand. The operator exists in two forms, which differ strictly in their value computation relative to the side effect of modifying the operand.

Prefix Decrement (--x)

In the prefix form, the operator is placed before the operand.
  • Side effect: The value of the operand is decremented by 1.
  • Value computation: The expression evaluates to the new, decremented value of the operand.

Postfix Decrement (x--)

In the postfix form, the operator is placed after the operand.
  • Side effect: The value of the operand is decremented by 1.
  • Value computation: The expression evaluates to the original, un-decremented value of the operand.

Technical Constraints and Behavior

Pointer Arithmetic When applied to a pointer, the -- operator does not simply subtract one byte from the memory address. Instead, it decrements the address by the size of the pointed-to type (sizeof(type)).
Rvalue Result In C, the result of both the prefix and postfix decrement operators is an rvalue (a temporary value), not an lvalue. Consequently, you cannot chain decrement operators or assign a value to the result of a decrement operation.
Sequence Points and Undefined Behavior The C standard dictates that the side effect of updating the operand’s value must be complete before the next sequence point. Modifying the same scalar object more than once between sequence points, or modifying it and reading its value for a purpose other than determining the value to be stored, invokes Undefined Behavior (UB).
Tired of Poor C Skills? Fix That With Deep Grasping!Learn More