C/C++ 为什么同一个地址存放不同数据?
// force to convert
const int x = 50;
int* y = (int *)(&x);// same address, but thecontent is different
*y = 200;
cout << "x: "<<x<<"address: "<<&x<<endl; //result: x: 50 address: 002CF880
cout << "*y: "<<*y<<"address: "<<y<<endl; //result: *y: 200 address: 002CF880
cout<<endl;
指针y的内容就是所指向变量x的地址啊,否则通过y怎么找到x?
但是答案就是50,200
为什么?