typedef union bigSmallEnd{ unsigned short a; unsigned char b[2]; }BSE; void testBSE() { BSE test; test.a = 0x0102; if (test.b[0] == (unsigned char) 0x02) { printf("小端\n"); } else { printf("大端\n"); } } int main(){ testBSE(); return 0; }
使用共用体测试大小端
猜你喜欢
转载自www.cnblogs.com/luyl/p/12408040.html
今日推荐
周排行