struct StudentRec //①声明结构体类型StudentRec{ char StuNum[20]; //②定义结构体的成员变量 char StuName[20]; //② 1.Dot “.” is called the member selection operator. 2. After the struct type declaration, the various members can be used i…
1)union是几个不同类型的变量共占一段内存(相互覆盖):struct是把不同类型的数据组合成一个整体 2)对齐方式略有区别:union不需要+,只需要拿出对齐后的最长 structure union Keyword struct defines a structure. Keyword union defines a union. Example structure declaration: struct s_tag { int ival; float fval; char *cptr; }…
空结构体占用的内存多大? struct d { }; int main() { struct d d1; struct d d2; printf("%d,%0x\n",sizeof(d1),&d1); //求内存大小,及结构体变量的地址 printf("%d,%0x\n",sizeof(d1),&d2); } 不同的编译器,分配的大小不一样,一般取0个字节或1个字节. 柔性数组:数组大小待定的数组,C语言中结构体最后一个元素可以是大小未知的数组,C语…