开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
问题(Question):
想要宣告一个4bits的正整数,
存放范围 0~15
不晓得这样的宣告方式正不正确?
struct {
unsigned int boy : 4;
unsigned int girl : 4;
} age;
不晓得这样是不是
boy 4 bits
girl 4 bits
我看网络资料他的参考Example是
struct {
unsigned int widthValidated : 1;
unsigned int heightValidated : 1;
} status;
The above structure requires 4 bytes of memory space for status variable, but
only 2 bits will be used to store the values.
宣告4 bytes 但是只有2 bits会存放到memory
感谢大大帮忙!