【发布时间】:2017-02-21 09:54:50
【问题描述】:
-
int* 到 char* :
int* pNum = new int[1]; pNum[0] = 57; char* pChar = reinterpret_cast< char* >(pNum);
结果:pChar[0] = '9'; //'9' ASCII 57
float* 到 char* :
float* pFloat = new float[1]; pFloat[0] = 57; //assign the same value as before char* pChar = reinterpret_cast< char* >(pFloat);
结果:pChar[0] = 'a';
那么为什么我会得到两个不同的结果?
感谢您的帮助。
【问题讨论】:
-
因为
float和int的含义不同
标签: c++ reinterpret-cast