struct stats { char top : 1; char bottom : 1; char side : 2; } MyStat;
I have seen this format with integers but how does the above char bit field work and what does it represent?
Thank You.
Char bit fields work in the same way as int, just the base type is 8-bit wide, not 32-bit. So you'd get a struct stats, which has the size of 1 byte, and 3 member variables, occupying a total of 4 bits.
2.1m questions
2.1m answers
60 comments
57.0k users