Code 1: -
struct emp
{
char a;
double b;
};
int main()
{
struct emp e;
printf("%p %p", (void*)&e.a, (void*)&e.b);
}
Output on my computer: -
OO28FF00 0028FF08
Since size charand doubleis equal to '1' and '8' respectively, and therefore, 0028FF00and 0028FF08are multiples of "1" and "8" respectively.
Code 2: -
struct emp
{
char a;
long double b;
};
int main()
{
struct emp e;
printf("%p %p \n", (void*)&e.a,(void*)&e.b);
}
Output: -
0028FF00 0028FF04
Since the size charand long doubleis equal to '1' and '12', respectively, but 0028FF04not a multiple of "12".
Why is the supplement not applicable in this case?
source
share