Precedence table
Refer the precedence table operators with higher precedence will be evaluated first.
in your case your using prefix increment ++
which has the same precedence level as deference operator *
.
so when you have both in the same expression Associativity of it should be considered which is right to left
++*p will be equivalent to ++(*p) the pointer is deference'd first then the value is incremented.
char *p="abcd";
i.e *p
is equal to a
and ++
on character will give you b
*++p will be equivalent to *(++p) the pointer is incremented first then deference'd
i.e ++p
will point to b
in the string then then *
deference will give you the b at position 2.
Change your input string you get a different answer. same answer your getting is just as the operation on the first character matches the operation for the second