In am doing some experiment in C pointers and trying to understand its behaviour. The following are my assumptions for the below codes. Correct me if I am wrong. I have the foll
Expression
*ptr++;
have value
*ptr
before incrementing ptr and then ptr is increment itself. There is no sense to write
*ptr++;
because the value of expression that is *ptr before incrementing of ptr is not used. So in fact the result of these expressions (expression-statements)
ptr++;
and
*ptr++;
is the same.
As for expressions *++ptr and ++*ptr then in this expression *++ptr at first ptr is incremented ( that is it will point to the second element of the array) and then dereferenced and its value is the value of the second element.
In this expression ++*ptr at first the value of the first element of the array is returned (that is 3) and then this value is incremented and you will get 4.