Friday, 16 August 2013

C- Size of structure when bit field is used and how it is stored in memory

C- Size of structure when bit field is used and how it is stored in memory

void main()
{
struct bitfield
{
signed int a:3;
unsigned int b:13;
unsigned int c:1;
};
struct bitfield bit1={2,14,1};
clrscr();
printf("%d",sizeof(bit1));
getch();
}
Why is size 4 bytes here? And how exactly these elements are stored in
memory?

No comments:

Post a Comment