Possible Duplicate:
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
I was trying to understand the concept of bit fields. But I am not able to find why the size of the following structure in CASE III is coming out as 8 bytes.
CASE I:
struct B    
{
    unsigned char c;  // +8 bits
} b;
sizeof(b); // Output: 1 (because unsigned char takes 1 byte on my system)
CASE II:
struct B
{
    unsigned b: 1;
} b;
 sizeof(b); // Output: 4 (because unsigned takes 4 bytes on my system)
CASE III:
struct B
{
    unsigned char c;  // +8 bits
    unsigned b: 1;    // +1 bit
} b;
sizeof(b); // Output: 8 
I don't understand why the output for case III comes as 8. I was expecting 1(char) + 4(unsigned) = 5.
 
     
     
     
     
     
    