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

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

When ever it is necessary to pack several objects into single machine word ,one common use is a set of single bit flags in application like compiler symbol tables.It is called bit fields. A bit field is a set of adjacent bits with a single implementation.
Syntax:

struct {
     unsugned int is_keyword : 1;
     unsigned is_extern :1;
     unsigned is_static : 1 ;
       } flags ;
flags.is_extern = flags.is_static = 1 ; 

By:Vivek Kr. Agarwal
Date:2003-01-09 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