可能重复:
'unsigned temp:3'表示什么
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};
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下:
struct的目的是什么,printf
只是输出0
所以我认为这些不是默认值,但它们是什么呢?
也有人可以解释我为什么A.a, A.b, A.c, A.d
输出1, 2, 1, 4
而不是1, 2, 3, 4