0
Output of C++ code
Why does this code output 4, and not 5? int x, *y; x=5; y=&x; *y++; x--; cout << x;
4 Answers
+ 5
*y++; <-- your incrementing the pointer...your NOT incrementing the value it's pointing to.
try:
(*y)++.
0
Because x-- will decremented it's value by 1 so it is 4.
0
but why doesnāt incrementing y increment x? y stores xās adress, so why doesnāt x increment as well?
0
ah ok, thanks rodwynnejones