版本:vc6 系统:win7#include <iostream>
//#include <cmath>using namespace std;int main()//小型测试专用工程
{
char buff[4];
int d = 0x0002DA2C;
memcpy(buff, &d, 4); for(int i=0;i<=3;i++)
cout<<hex<<(int)buff[i]<<endl; system("pause");
return 0;
}
如图,buff[1]显示的是-38而不是218,即是0xFFFFFFDA而不是0x000000DA?求解...
//#include <cmath>using namespace std;int main()//小型测试专用工程
{
char buff[4];
int d = 0x0002DA2C;
memcpy(buff, &d, 4); for(int i=0;i<=3;i++)
cout<<hex<<(int)buff[i]<<endl; system("pause");
return 0;
}
如图,buff[1]显示的是-38而不是218,即是0xFFFFFFDA而不是0x000000DA?求解...
unsigned char buff[4]; 应该不会出错。