送分!如何输出或者得到位数据?
typedef struct myStruct{ int OneBit :1;}Bit_t;int main(){ Bit_t stVar = 0; int arr[2] = {0x40,0x11}; stVar.OneBit = arr[0] & 0x40;}
typedef struct myStruct { unsigned int OneBit :1; }Bit_t; Bit_t stVar; stVar.OneBit = 0; printf("%d\n",stVar.OneBit); stVar.OneBit = 1; printf("%d\n",stVar.OneBit);
[解决办法]
01000000
00010001 按位与
00000000 则stVar.OneBit为0