#include<stdio.h>
struct stu
{
unsigned int gen:1;
unsigned int sub:10;
union
{
int maths:14;
int sci:6;
char lang:8;
int soc:3;
}u;
};
int main()
{
struct stu a;
printf("%d",sizeof(a));
return 0;
}
It prints : 8 byte....
Please help me understand the padding in case of bit fields...
It's completely up to the compiler. I think many have options via #pragma that let you adjust it, though.