readdata.c

来自「编写一程序」· C语言 代码 · 共 16 行

C
16
字号
#include "Score.h"
void ReadData(Student stu[] , int count)
{
	FILE *fp;
	int i;
	char ch[10];
	if((fp = fopen("Score.dat","r")) == NULL)
	{
		printf("\tCan't open the file: Score.dat.\n\tPress AnyKey to Exit... ");
		getch();
		exit(0);
	}
	fscanf(fp,"%s%s%s%s%s",ch,ch,ch,ch,ch);
	for(i = 0 ; i < count ; i++)
		fscanf(fp,"%s%s%d%d%d",stu[i].id,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?