In C what is meant by padding of bits? Consider the following structure,
struct number {
int a;
char b;
int c;
};
What is the size of this structure? An integer takes 4 bytes, char takes 1 and the third integer 4 bytes. Total 9 bytes. This is wrong. We can see the size of the structure is 12 bytes. What happens here? the compiler pads 3 bytes to char element. This is for proper alignment. In a 32 bit processor it checks the next data only after 32 bits. Else the compiler will have related problems. Now the compiler knows each data is 4 bytes wider. So the benefits.