Search code examples
cpost-incrementpre-increment

what is the difference between ++*var++ and ++Var++?


What is difference between ++*var++ and ++var++ ? why ++*var++ is working while ++var++ results with lvalue required error in C?


Solution

  • ++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.