Structures and Unions in C, determining size and accessing members
问题 All, Here is an example on Unions which I find confusing. struct s1 { int a; char b; union { struct { char *c; long d; } long e; }var; }; Considering that char is 1 byte, int is 2 bytes and long is 4 bytes. What would be the size of the entire struct here ? Will the union size be {size of char*}+ {size of double} ? I am confused because of the struct wrapped in the union. Also, how can I access the variable d in the struct. var.d ? 回答1: With no padding, and assuming sizeof(int)==sizeof(char *