Unfortunately, structure in C-language does not have the capability of reducing the memory space. This back drop can be achieved by using Bit Field in C code.
If the structure members are specified in terms of bits, then it is called as "bit-field". They can be mainly used to increase the memory efficiency by giving a finite space to each member. Bit Field in C packs the data in a structure.
Some functions of Bit-fields
Bit-fields behave as flags for determining the true or false values when required.
If the bit field is empty, then that field can be accommodated to next coming bit.
Portability of C decreases, if we use bit-fields as they maintain constant memory structure.
Bit field are not given any address, so pointers don't work on bit-fields.
The alternate to Bit Field in C are integers i.e. int or unsigned.
Using bit-fields is suitable for low-level programming tasks because those machines support bit addressing.
The main drawback is, bit-fields cannot be used for operators like sizeof() as they occupy the memory in terms of bytes.
Bit Field Members shares the same bytes in a single word of memory.
Syntax
datatype bit-field_name :(length of bit-field)
where, data-type should always be int (or) unsigned.Eg:
struct book
{
unsigned author : 4
unsigned page: 1
unsigned subject :2
};