#include<stdio.h>
struct student
{
char name[10];
int num;
float math;
float chinese;
float english;
float average;
};
main()
{
struct student stu[5];
int i;
FILE *fp;
if((fp = fopen("E:\\vc++6.0\\MSDev98\\MyProjects\\文件3\\stud.txt","r"))==NULL)
{
printf("the file opening error!!");
}
else
{
for(i = 0;i < 5;i++)
{
fscanf(fp,"%s,%d,%f,%f,%f,%f",stu[i].name,&stu[i].num,&stu[i].chinese,&stu[i].english,&stu[i].math,&stu[i].average);
}
fclose(fp);
for(i = 0;i < 5;i++)
{
printf("%s\n",stu[i].name);
}
}
}
tom1,1001,94.00,95.00,96.00,95.00
tom2,1002,95.00,92.00,93.00,93.33
tom3,1003,95.00,96.00,94.00,95.00
tom4,1004,95.00,92.00,94.00,93.67
tom5,1005,94.00,91.00,98.00,94.33
蛊毒传说
相关分类