链接:https://www.nowcoder.com/questionTerminal/cbecdf1ddab543eeb6d87d1bd23d7d0c
来源:牛客网
有如下一段代码(unit16_t为2字节无符号整数,unit8_t位1字节无符号整数);
1
2
3
4
5
6
7
8
9
10
11
12
|
union X { unint16_t a; struct Z { unint8_t m; unint8_t n; }z; }; union X x; x;a = 0x1234; |
请问x.z.n在大字节序和小字节序机器上的值分别为多少()?
-
0x34,0x12
-
0x12,0x34
-
0x1234,0x1234
-
0x1234,0
-
0,0x1234
答案:A 错选:E
问的是x.z.n 在大端小端机器上的值,记住大端和阅读习惯一致
所以大端是0x34,小端0x12