69,373
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
typedef union
{
unsigned char a;
struct
{
unsigned bit0:1;
unsigned bit1:1;
unsigned bit2:1;
unsigned bit3:1;
unsigned bit4:1;
unsigned bit5:1;
unsigned bit6:1;
unsigned bit7:1;
}bit;
}IO;
void main()
{
IO io;
io.a='P';//0x50-->01010000
cout <<io.bit.bit0<<endl;
cout <<io.bit.bit1<<endl;
cout <<io.bit.bit2<<endl;
cout <<io.bit.bit3<<endl;
cout <<io.bit.bit4<<endl;
cout <<io.bit.bit5<<endl;
cout <<io.bit.bit6<<endl;
cout <<io.bit.bit7<<endl;
}
//
输出为:
0
0
0
0
1
0
1
0