Why output is incorrect?
I think the output should be:-
19 for the struct inside the union
19 again the same because Union reserves memory for the largest variable.
43 and the outside Struct is 43 because 19+20+4=43
#include<stdio.h>
//structure
//======================================================
struct {
char a[20];
int b;
union {
double c;
struct {
char d[15];
float e;
}x;
}y;
}z;
//main function
//======================================================
int main() {
printf("%u\n%u\n%u\n",sizeof(z.y.x),sizeof(z.y),sizeof(z));
return 0;
}
//Output is 20 24 48
//Assumed 19 19 43