- 论坛徽章:
- 5
|
我的主机是小端模式
m.b=99--->执行后union 数据二进制 01100011 00000000 00000000 00000000
m.c=123-->执行后union 数据二进制 01111011 00000000 00000000 00000000
m.a[2]=20->执行后union 数据二进制 01111011 00000000 00010100 00000000
打印m.d-->即最前面8位,011111011=123
这时候b为值1310843- 13 m.b=99;
- (gdb) n
- 14 m.c=123;
- (gdb) p m
- $1 = {a = "c\000\000", b = 99, c = 99, d = 99 'c'}
- (gdb) n
- 15 m.a[2]=20;
- (gdb) p m
- $2 = {a = "{\000\000", b = 123, c = 123, d = 123 '{'}
- (gdb) n
- 16 printf("%d\n",m.d);
- (gdb) p m
- $3 = {a = "{\000\024", b = 1310843, c = 123, d = 123 '{'}
- (gdb) n
复制代码 |
|