What is difference between ++*var++ and ++var++ ? why ++*var++ is working while ++var++ results with lvalue required error in C?
++var++
is grouped as ++(var++)
and that results in a compilation failure since var++
is not an lvalue
. (Informally speaking this means you can't put it on the left hand side of an assignment).
++*var++
is grouped as ++(*(var++))
which means increment the pointer var
by 1 using pointer arithmetic, then increase the dereferenced value of the initial value of var
by 1.