union {
struct {
unsigned b0: 1;
unsigned b1: 1;
unsigned b2: 1;
unsigned b3: 1;
unsigned b4: 1;
unsigned b5: 1;
unsigned : 2; //最高两位保留
} oneBit;
//unsigned char allBits;
} myFlag;
//需要存取其中某一位时可以
myFlag.oneBit.b3=1; //b3 位置1
//一次性将全部位清零时可以
myFlag.allBits=0; //全部位变量清0
请高手指点下,在下先谢啦,急! |