定义位字段时,可以在中间保留一些位空白,并将成员分配给特定位。为什么中间有些空位?
struct product {
unsigned int code : 6; // product code : 6 bit
unsigned int : 10; // not use 10 bit
unsigned int color : 5; // product color : 5 bit
unsigned int : 5; // not use 5 bit
unsigned int size : 6; // product size : 3 bit
};
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我不使用中间的钻头
c ×1