#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
union flag{
unsigned char byte;
struct {
unsigned char a0:1;
unsigned char a1:1;
unsigned char a2:1;
unsigned char a3:1;
unsigned char a4:1;
unsigned char a5:1;
unsigned char a6:1;
unsigned char a7:1;
} bit;
};
flag aaa;
aaa.byte = 210;
printf("%d",aaa.bit.a7);
printf("%d",aaa.bit.a6);
printf("%d",aaa.bit.a5);
printf("%d",aaa.bit.a4);
printf("%d",aaa.bit.a3);
printf("%d",aaa.bit.a2);
printf("%d",aaa.bit.a1);
printf("%d\n",aaa.bit.a0);
printf("%X\n",aaa.byte);
//scanf("%d",&n);
//printf("%d",n);
system("pause");
return EXIT_SUCCESS;
}
留言列表