我有的是这个
struct Record
{
unsigned char cat;
unsigned char len[2]={0x00, 0x1b}; // can't put short here because that
// whould change the size of the struct
unsigned char dat[253];
};
Record record;
unsigned short recordlen = *((unsigned short*)record.len);
这导致recordlen=0x1b00
而不是0x001b
与*reinterpret_cast<unsigned short*>(record.len)
你能解释一下为什么吗?我应该怎么做?