Why can I not increment the value of an int variable by using "++" when working with pointers?

M.I*_*oan 0 c++ pointers increment

I am trying to increment the value of an element inside an array, using a pointer storing that element's address.

When I write it as " p++; " it does not work, whereas if I write it as *p=*p+1 it works.

*p=*p+1; // this increments the value
*p++; //while this does not
Run Code Online (Sandbox Code Playgroud)

I am expecting both ways to work

use*_*670 5

operator ++ has higher precedence than dereference so *p++ increments the pointer and then performs dereference. If you want to increment the value it initially points to then you need to add parentheses: (*p)++;