- 论坛徽章:
- 0
|
回复 #6 204tian 的帖子
还是不行啊!
但改成:
#include<stdio.h>
#include<string.h>
#define SIZE 10
struct student_type
{
int num;
char name[5];
int age;
char sex;
float English;
float PE;
float Computer;
float Maths;
float Progrome;
}std1[SIZE],std2[SIZE];
void main()
{
FILE *fp;
int i;
char infile[10];
printf("Enter the infilename:\n");
scanf("%s",infile);
if ((fp = fopen(infile,"rb")) == NULL)
{
printf("cannot open infile\n");
return;
}
for (i = 0; i < SIZE; i++)
{
if(! feof(fp))
{
fscanf(fp,"%d %s %d %s %f %f %f %f %f",&std1[i].num,std1[i].name,&std1[i].age,std1[i].sex,
&std1[i].English,&std1[i].PE,&std1[i].Computer,&std1[i].Maths,&std1[i].Progrome);
printf("%d %s %d %s %f %f %f %f %f\n",
std1[i].num,std1[i].name,std1[i].age,std1[i].sex,
std1[i].English,std1[i].PE,std1[i].Computer,std1[i].Maths,std1[i].Progrome);
}
else
printf("file write error\n");
}
fclose (fp);
}
一点都不能运行! |
|