位域对齐问题
1 #include <stdio.h>2 #pragma pack(1)
3
4 struct a
5 {
6 unsigned char a:1;
7 unsigned char b:2;
8 unsigned char c:6;
9 // unsigned char d:4;
10 unsigned char f;
11 unsigned char g:4;
12 unsigned long x;
13
14 }B;
15
16 int main(void)
17 {
18 printf("%d\n",sizeof(B));
19
20 }
~
~答案是8???我觉得是9.。。请帮忙解答!
~