请看代码:#include <stdio.h> #include <stdlib.h> int main() { union Tag_uMyUnion{ int i; short s; char ch; }*p, u; p = &u; u.i = 0x12345678; short *ps = (short*)&u; printf("
最近碰到一道题,顺带复习一下union的数据分布,题目如下:union packet { struct packet_bit { unsigned char a:2; unsigned char b:3; unsigned char c:4; } bit; int i; } data; int main() { data.i = 0; data.bit.a = 1; d
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号