What is the use of bit fields in a structure declaration?

What is the use of bit fields in a structure declaration?

In C we store the integer members into the memory space.This memory space saving structures is named as bit fields and declared width in bits  explicitly. 

The Representation of declaring a bit field is given below: 

>>-specifier_type-+---------+--:-constt_expression-;-><
                  'declarator'
  A bit field declaration may not use type qualifiers,constt or volatile.

In C, C99 standard requires the allowable data types for bit field to include qualified and unqualified _Boolean, signed integer and unsigned integer. In addition, this supports the following types.

    # int
    # long, signed long, unsigned long
    # short, signed short, unsigned short
    # char, signed char, unsigned char
    # long long, signed long long, unsigned long long 

By default  bit field(integer type) is unsigned.


By:Vivek Kr. Agarwal
Date:2031-12-08 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Subjective Links

C Subjective interview questions and answers for experienced and fresher