学生信息管理系统c语言数组
时间: 2023-09-15 19:16:42 浏览: 66
学生信息管理系统可以使用数组来存储学生信息。以下是一个简单的示例,其中使用了一个结构体来表示学生信息,以及一个数组来存储多个学生的信息:
```
#include <stdio.h>
#include <string.h>
// 定义学生信息结构体
struct Student {
char name[20];
int age;
float score;
};
int main() {
// 定义学生信息数组
struct Student students[100];
int count = 0;
// 添加学生信息
strcpy(students[count].name, "张三");
students[count].age = 18;
students[count].score = 90.0;
count++;
strcpy(students[count].name, "李四");
students[count].age = 19;
students[count].score = 85.5;
count++;
// 输出学生信息
for (int i = 0; i < count; i++) {
printf("姓名:%s,年龄:%d,成绩:%f\n", students[i].name, students[i].age, students[i].score);
}
return 0;
}
```
在上面的示例中,定义了一个结构体`Student`,用于存储学生的姓名、年龄和成绩。然后定义了一个大小为100的`students`数组来存储多个学生的信息。添加学生信息时,可以使用`strcpy`函数来复制学生姓名,然后直接给年龄和成绩赋值。最后,使用循环遍历数组,并输出每个学生的信息。