The postfix ++
and --
operators essentially have higher precedence than the prefix unary operators. Therefore, *p++
is equivalent to *(p++)
; it increments p
, and returns the value which p
pointed to before p
was incremented.
To increment the value pointed to by p
, use (*p)++
(or perhaps ++*p
, if the evaluation order of the side effect doesn't matter).