I’m trying to increment pointer. I was sure that it is similar to do i+=1
, but I’m getting adress.
#include \"stdafx.h\"
#include
++
has a higher operator precedence than the pointer dereference operator *
.
So what *a++
does is to return the value of i
(the old value of *a
) before incrementing the pointer value.
After that expression has been evaluated, a
now points to something other than the address of i
, and the behaviour of a subsequent *a
is undefined.
If you want to increment i
via the pointer, then use (*a)++;