定义一个 struct student 类型的结构指针,在主函数中用结构指针实现一个学生信息的输入和输出。
输入:668899 Ken 80 90 99
输出:668899 Ken 80 90 99
定义一个 struct student 类型的结构指针,在主函数中用结构指针实现一个学生信息的输入和输出。
输入:668899 Ken 80 90 99
输出:668899 Ken 80 90 99
struct Student
{
int id;
char name[20];
int score[3];
};
int main()
{
struct Student *s;
s = (struct Student *)malloc(sizeof(struct Student));
scanf("%d%s", &s->id, s->name);
for (int i = 0; i < 3; i++)
scanf("%d", &s->score[i]);
printf("%d %s", s->id, s->name);
for (int i = 0; i < 3; i++)
printf(" %d", s->score[i]);
return 0;
}