An array is not a pointer. In most expressions, an array is converted to a pointer automatically. The result of this conversion is no longer the array; it is just a pointer value.
The ++
operator cannot operate on a mere value. It must have an object to act on.
For example, consider int x = 3; (x+5)++;
. The result of x+5
is 8. It is not x
. The result is just a value, not an object, so there is no object containing 8 that ++
can operate on. This is an error.
Similarly, if a
is an array of int
, then a++
is equivalent to ((int *) a)++
. The ++
is not trying to act on the a
; it is trying to act on the result of converting a
to a pointer.
An array expression is always converted to a pointer to the first element except when the array expression is the operand of sizeof
, &
, or _Alignof
or is a string literal used to initialize an array.