Pointer p contains the address of the structure variable bit1 .
I believe that your system has a small endian addressing, because of which the variable b is placed at the location indicated by the pointer p and * p, prints the contents of the first two bytes of bit1 .
In your case b=3 (000011)
But two bytes contain
00000000 00001100 (12) ------ ^ | Value of b
To better understand this,
change the value of b to 5 (000101) as follows:
struct bitfield bit1={1,1,5};
Then your output will be 20 because
00000000 00010100 (20) ------ ^ | Value of b
The bitfield structure packs a , c and b into an unsigned integer. The size of unsigned integers is 4 bytes .
Deepu
source share