#pragma pack(2)
struct hai
char ch1;
char ch2;
char ch3;
char ch4;
char ch5;
int main()
printf("%d \n",sizeof(s));
return 0;

output : 5

while i changing the statemnt in 2nd line as #pragma pack(4) ,then both outputs are same. can u give me solutions ?

It really depends on how your compiler implements the pack pragma, but usually it packs on the lesser of the value given or the natural boundary for the type. There is no address boundary less than char, so no matter what argument you give to pack , it will use the natural boundary for char.