C语言
-
结构体数组、
-
定义结构体数组
-
单独定义、
-
struct a { int m; int d; int y; }; struct b { int xuhao; char ming[]; int xingbie; int nianling; char dizhi; struct a rqi;//结构体套结构体、 }; int main() { struct b c[5];//单独定义
-
-
定义结构时定义
-
struct a { int m; int d; int y; }; struct b { int xuhao; char ming[50]; int xingbie; int nianling; char dizhi; struct a rqi;//结构体套结构体、 }d[5];//全局定义、
-
-
定义时初始化、
-
定义时每个元素使用{},间隔
-
struct b c[5] = { {41,"姓名",1, 23,34}, {45,"姓名",1, 25,31}, {46,"姓名",1, 20,32}, };
-
struct b c[5] = { {41,"姓名",1, 23,34}, {41,"姓名",1, 20,34}, {41,"姓名",1, 27,34}, }; c[1].nianling++; printf("nianling=%d\n", c[1].nianling);
-
-
、
-
-
-
结构体指针、
-
结构体变量的指针、指向该结构体变量所占的内存段的起始地址、
-
也可以指向结构体数组中的元素、
-
struct b d; struct b* c; c = &d; d.nianling = 29; (*c).nianling = 40; c->nianling = 31; printf("ninliang=%d\n", c->nianling);
-
-
-> 指向结构体成员运算符、
-
-
用指向结构体的指针做函数参数、