#include<stdio.h>#include<stdlib.h>#include<time.h>int main (void){struct Test
{unsignedint a:1;unsignedint b:1;unsignedint c:2;//不能超过32};struct Test test;
test.a =0;
test.b =1;
test.c =2;printf("%d %d %d ",test.a,test.b,test.c);printf("%d ",sizeof(test));//4 4的整数倍printf("%d ",sizeof(int));//4return0;}
位运算符
#include<stdio.h>#include<stdlib.h>#include<time.h>int main (void){int value =1;while(value <1024){
value <<=1;//value = value <<1;printf("value = %d\n",value);}printf("\n------\n");while(value >0){
value >>=2;printf("value = %d\n",value);}return0;}
C语言位域#include<stdio.h>#include<stdlib.h>#include<time.h>int main (void){ struct Test { unsigned int a:1; unsigned int b:1; unsigned int c:2; //不能超过32 }; struct Test test; test.a