These statements declare Bit Fields .
This means that a takes up the memory of bit 1 , and c takes up the memory of bit 3 .
The size of the structure will be:
At least 4 bits + pad (bit)
And most likely it will be 8 bits ie: 1 byte
Because,
If a series of bit fields cannot be combined with an int size, indentation may be performed. The number of indents is determined by the alignment characteristics of the structure elements.
What are bit fields?
From the IBM documentation:
Both C and C ++ allow integer members to store less in memory spaces than the compiler normally allowed. These space-saving elements are called bit fields, and their width in bits can be explicitly declared. Bit fields are used in programs that should make the data structure conform to a fixed representation of the hardware and are unlikely to be portable.
The syntax for declaring a bit field is as follows:
<P →> - type_specifier - + ------------ + -: - constant_expression -; ---> <'-declarator -'A bit field declaration contains a type specifier, followed by an optional declarator, a colon, a constant integer expression that indicates the field width in bits and a semicolon. A bit field declaration may not use any of the classifiers, const or volatile.
source share