#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct
{
unsigned int a:4;
unsigned int b:4;
int c:4;
}test;
void print_bin(int n)
{
int l = sizeof(n)*8;//总位数。
int i;
if(l == 0)
{
printf("0");
return;
}
for(i = l-1; i >= 0; i --)
{
if(i % 4 == 3) printf(" ");
printf("%d", (n&(1<<i)) != 0);
}
printf("\n");
}
int main()
{
test a;
a.a = 14;
a.b = 15;
a.c = 9;
printf("sizeof(a): %lu\n", sizeof(a));
print_bin(a.a);
print_bin(a.b);
print_bin(a.c);
return 0;
}
03-05
1241
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)