参考:https://blog.youkuaiyun.com/fightingintherain/article/details/68951741
char temp_data[4];
memset(temp_data, '0', 4);
char m_hexCommand[4]={0x41,0xC9,0x29,0x5C};
temp_data[0] = m_hexCommand[3];
temp_data[1] = m_hexCommand[4];
temp_data[2] = m_hexCommand[5];
temp_data[3] = m_hexCommand[6];
float temp;
unsigned int n;
memcpy(&n,temp_data,1);
n = n<<8;
memcpy(&n,&temp_data[1],1);
n = n<<8;
memcpy(&n,&temp_data[2],1);
n = n<<8;
memcpy(&n,&temp_data[3],1);
memcpy(&temp,&n,4);

这段代码涉及C++中的数据处理,包括将hexCommand数组的特定部分复制到temp_data,然后通过一系列位移和memcpy操作将temp_data转换为无符号整数n,最后将n转换为浮点数floattemp。主要操作包括字节填充、位左移和内存复制。

被折叠的 条评论
为什么被折叠?



