#include <stdio.h> union u{ int i; char c; }ui; int main(void) { ui.i=512; ui.c='a'; printf("%i",ui.i); printf("%c",ui.c); // your code goes here return 0; }
结构体变量,覆盖,从低地址开始存
00000000 00000000 00000010 00000000=512
00000000 00000000 00000000 97=97
覆盖后
00000000 00000000 00000010 97
取int为4字节=512+97=609
取char 1字节,直接为97还是a
Success time: 0 memory: 2292 signal:0
609a