Hi rochy,
can u check the below programs outputs
Code:
#include<stdio.h>
#pragma pack(2)
struct s
{
char ch1;
char ch2;
char ch3;
char ch4;
char ch5;
char ch6;
char ch7;
};
int main()
{
struct s s1;
printf("%d\n",sizeof(s1));
return 0;
}
output :7
Code:
#include<stdio.h>
#pragma pack(2)
struct s
{
char ch1;
char ch2;
int i;
char ch7;
};
int main()
{
struct s s1;
printf("%d\n",sizeof(s1));
return 0;
}
output 8:
please can u let me know ur suggestins , i little bit confusion how these bit will allign in memory