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

Showing Answers 1 - 1 of 1 Answers

When the storage is at premium , it may be 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. A bit field or field for short is a set of adjacent bits with a single implementation - defined storage unit.
struct {
     unsugned int is_keyword : 1;
     unsigned is_extern :1;
     unsigned is_static : 1 ;
} flags ;

flags.is_extern = flags.is_static = 1 ; to tun this bit on.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions