You are playing with two things here, neither of which I am sure you understand well.
Pre- and post-increment operations can be difficult to understand, because they are "side effect" operators: they change the value of variables without an obvious assignment.
In your case,
x = *(ptr)++;
is the equivelant of saying this:
x = *ptr;
ptr = ptr + 1;
And
y = ++*(ptr);
is the equivelant of this:
*ptr = *ptr + 1;
y = *ptr;
The second version changes the value in the array
a
instead of altering the pointer itself.
Run the code through the debugger and look closely at what is happening to the values of
ptr
and the array and you'll see what I mean.
It might be worth a quick look here:
Why does x = ++x + x++ give me the wrong answer?[
^] before you start diving into complicated pre- and post- increment statements!