✔ 最佳答案
They both have similar syntax, but the memory allocations are different.
Struct variables add up, and do not share.
Union variables share the same memory, so one can destroy another. We do this to save memory space.
An example:
union a1(
int x;
char y;
double z;
)u1;
u1.x=4;
u1.y='a';
printf("%d",u1.x)
You will NOT get 4, because y has destroyed the value, since x,y and z share the same memory space. The space occupied by union is the greatest of them, namely double in this case (8 bytes).
I