void main()
{
struct employee
{
unsigned id: 8;
unsigned sex:1;
unsigned age:7;
};
struct employee
emp1={203,1,23};
clrscr();
printf("%d\t%d\t%d",emp1.id,emp1.sex,emp1.age);
getch();
}
Output: 203 1 23
We can access the data
member in same way, how bit data is stored
in the memory:
Minimum size of
structure which data member in bit is two byte i.e. 16 bit. (This is called word
size of microprocessor. Word size depends on microprocessor. Turbo c is based
on 8086 microprocessor which word size is two byte.)
Bits are filled in from right to left
direction. 8 bit for id, 1 bit for sex and 7 bit for age.
No comments:
Post a Comment