lt76.c
来自「陈孟建等编著的C语言教程附带光盘」· C语言 代码 · 共 27 行
C
27 行
# include "stdio.h"
# include "stdlib.h"
# define SIZE 6
struct student_type
{ char name[10];
int num;
int age;
float score;
} stu[SIZE];
void save()
{ FILE *fp;
int i;
if ((fp=fopen("stu_scor.dat","wb"))==NULL)
{ printf("不能打开该文件\n");
return;
}
for (i=0;i<SIZE;i++)
if (fwrite(&stu[i],sizeof(struct student_type),1,fp)!=1)
printf("文件写入错误\n");
}
void main()
{ int i;
for (i=0;i<SIZE;i++)
scanf("%s%d%d%f",stu[i].name,&stu[i].num,&stu[i].age,stu[i].score);
save();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?