void test7(void)
{
typedef union
{
unsigned int allBits;
struct
{
unsigned a :4;
unsigned b :4;
unsigned c :4;
unsigned d :4;
};
}Sta;
Sta ss;
ss.allBits=0x1234;
printf("0x%x\n",ss.allBits);
//主意a是低4位,b是高4位
ss.a=0x1;
ss.b=0x2;
ss.c=0x03;
ss.d=0x04;
printf("0x%x\n",ss.allBits);
printf("sizeof(char) = %d\n",sizeof(char));
printf("sizeof(unsigned char) = %d\n",sizeof(unsigned char));
printf("sizeof(int) = %d\n",sizeof(int));
}
|