可能是重复问题:
What does 'unsigned temp:3' means
struct Test
{
unsigned a : 5;
unsigned b : 2;
unsigned c : 1;
unsigned d : 5;
};
Test B;
printf("%u %u %u %u", B.a, B.b, B.c, B.d); // output: 0 0 0 0
static struct Test A = { 1, 2, 3, 4};
请问有人能解释一下在struct中:
的作用是什么吗?printf
输出了0
,所以我猜这不是默认值,那它们是什么呢?
还有,为什么A.a, A.b, A.c, A.d
输出的是1, 2, 1, 4
而不是1, 2, 3, 4
呢?