#1
1st February 2013, 12:27 PM
| |||
| |||
Bits in C STRUCT
Please provide me the syntax of using Bits in Structure in C.
|
#2
4th February 2013, 02:53 PM
| |||
| |||
Re: Bits in C STRUCT
Both C and C++ allow integer members to be stored into lesser memory spaces than the compiler would ordinarily allow. These saving space structure members are called bit fields, and their width in bits can be explicitly declared. Bit fields are used in programs that force a data structure to correspond to a fixed hardware representation The syntax for declaring a bit field is as follows: >>-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 either of the type qualifiers, const or volatile. |