C语言教程:结构体数组(集合)
C语言编程中可以将一系列结构体来存储不同数据类型的许多信息。 结构体数组也称为结构的集合。 我们来看一个数组结构体的例子,存储5位学生的信息并打印出来。创建一个源文件:structure-with-array.c,其代码实现如下 -
#include #include #include struct student { int rollno; char name[10]; }; // 定义可存储的最大学生数量 #define MAX 3 void main() { int i; struct student st[MAX]; printf("Enter Records of 3 students"); for (i = 0;i