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 Respostas
+ 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