int 转换为 short: uint32_t sum=0xFFFF1234; uint16_t *p= (uint16_t *) ∑ uint16_t checksum=p[0];
check-sum is 0x1234.
Here is another way:
union ToShort { uint32_t sum; uint16_t checksum[2]; } toShort; toShort.sum=0xFFFF1234; cout << hex << toShort.checksum[0];
output is 1234.