我自己的过不了 求助。
程序代码:
#include<stdio.h>
typedef struct stu {
char sn[4];
double score[3];
} *Pstu;
int main()
{
int i = 10;
FILE *f, *f1;
f = fopen("f11.txt", "r");
f1= fopen("f11a.txt", "w");
Pstu pp = (Pstu) malloc(sizeof(struct stu) * i);
int j = 0;
while (fscanf
(f, "%s %f %f %f", &pp[j].sn, &pp[j].score[0],
&pp[j].score[1], &pp[j].score[2]) != EOF) {
fprintf(f1, "%s %f %f %f %f\n", pp[j].sn, pp[j].score[0],
pp[j].score[1], pp[j].score[2],
(pp[j].score[0] + pp[j].score[1] +
pp[j].score[2]) / 3);
j++;
}
return;
}
[view@localhost c]$cat f11a.txt
001 0.000000 0.000000 0.000000 0.000000
002 0.000000 0.000000 0.000000 0.000000
003 0.000000 0.000000 0.000000 0.000000