结构体-位段

#include <stdio.h>

struct S
{
int a : 2;     //a 只需要2个比特位
int b : 5;   // b 只需要5个比特位
int c : 10;
int d : 30;

};
int main(void)
{
struct S s;
printf("%d\n", sizeof(s)); // 8个字节
return 0;
}

 

posted @ 2022-04-29 17:50  藏进夜里躲在光下  阅读(35)  评论(0)    收藏  举报