#include<stdio.h>
#include<stdlib.h>
union test
{
int a
;
char b
;
short d
;
};
int main()
{
union test tmp
;
printf("%p ,%p ,%p\n",&tmp
.a
,&tmp
.b
,&tmp
.d
);
printf("sizeof(union test) = %lu\n",sizeof(union test
));
tmp
.d
=0xaabbccdd;
printf("c1 = %x\n",tmp
.d
);
printf("a = %x\n",tmp
.a
);
printf("b =%x\n",tmp
.b
);
tmp
.a
=0x11;
printf("c1 = %x\n",tmp
.d
);
printf("a = %x\n",tmp
.a
);
printf("b =%x\n",tmp
.b
);
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-51649.html