lt71.c
来自「陈孟建等编著的C语言教程附带光盘」· C语言 代码 · 共 26 行
C
26 行
# include "stdio.h"
# define N 30
struct student_type
{ char name[8];
int num;
int age;
float score;
} stud[N];
void save()
{ FILE *fp;
int i;
if ((fp=fopen("st_score","wb"))==NULL)
{ printf("cannot open file\n");
return;
}
for (i=0;i<N;i++)
if (fwrite(&stud[i],sizeof(struct student_type),1,fp)!=1)
printf("file write error\n");
}
void main( )
{ int i;
for (i=0;i<N;i++)
scanf("%s%d%d%s",stud[i].name,&stud[i].num,&stud[i].age,stud[i].score);
save( );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?