Google News
logo
C-Language - Interview Questions
Please explain bit fields in C.
Bit fields are variables defined with a predefined width (size) inside a structure. The general syntax of a bit field is :
 
struct {
    type [member_name] : width ;
};
 
type : Integer type, such as int and signed int, determining how a bit field’s value is interpreted.
 
member-name : Name of the bit field.
 
width : Number of bits in the bit field. Must be less than or equal to the bit width of the specified integer type.
Advertisement