I was trying to do some experiments with pointers in C++, I did understand the concepts of precedence a bit but the following program is mingling with my mind and am unable to comprehend it
CODE:
#include <iostream>
using namespace std;
int main() {
int x = 9;
int* ptr = &x;
cout << "The value of x is " << x << endl << "The value of ptr is " << ptr << endl << *ptr << endl << (*ptr)++ << endl << (*ptr)++ << endl << (*ptr)++ << endl;
return 0;
}
in this program gave the initial value to x as 9 and i expect the compiler to give me value of x as 9 and then increment it using pointers so i expected the answer to be as 9,Address,9 ,10,11,12 but instead the answer i get in every compiler is that the value of x is 12 and rest is like this 12,Address,11,10,9 Please help me understand this am a newbie in C++