在小端模式上存储:
typedef struct node{
unsigned char a:2; //a占低2bit
unsigned char b:2;
unsigned char c:4; //c占高4bit
}Node;
union a{
struct node A; (union型数据所占的空间等于其最大的成员所占的内存)
char b;
}B;
union {
int a;
char b;
}C;
int main()
{
printf("the isze of union is %d\n",sizeof(B));//1
B.b=100;
printf("the B.A.c=%d\n",B.A.c);//6
}
100=0110 01 00 -------->(1byte)
c b a