我在设置(short int)的上下字节时遇到问题。请查看我的代码,它只返回数字 1 但必须返回 55 。
int number = 55;
int mynumber = 0;
//convert short int to char.
char upper = number >> 8;
char lower = number && 8;
//convert char to short int .
mynumber = (mynumber & 0xff00) | lower;
mynumber = (mynumber & 0x00ff) | (upper << 8);
printf("%i",mynumber);