分类: C/C++
2013-05-18 16:46:53
struct bs { int a:8; int b:2; int c:6; }; |
struct bs { int a:8; int b:2; int c:6; }data; |
struct bs { unsigned a:4 unsigned :0 /*空域*/ unsigned b:4 /*从下一单元开始存放*/ unsigned c:4 } |
struct k { int a:1 int :2 /*该2位不能使用*/ int b:3 int c:2 }; |
main(){ struct bs { unsigned a:1; unsigned b:3; unsigned c:4; } bit,*pbit; bit.a=1; bit.b=7; bit.c=15; printf("%d,%d,%d\n",bit.a,bit.b,bit.c); pbit=&bit; pbit->a=0; pbit->b&=3; pbit->c|=1; printf("%d,%d,%d\n",pbit->a,pbit->b,pbit->c); } |