#include<stdio.h>
struct score
{
float score1[10];
float score2[10];
float score3[10];
};
struct student
{
char name[10];
struct score scoremore;
};
int main()
{
int i;
struct student iboy;
FILE* fp;
if ((fp = fopen("c:\\f\\stduent.txt", "w")) == NULL)
{
printf("open file error!\n");
exit(0);
}
printf("Please enter the student name and three score:\n");
scanf("%s %.1f", iboy.name,iboy.scoremore.score1,iboy.scoremore.score2,
iboy.scoremore.score3);
printf("Please enter the student name and three score again(ctrl+z to quit):\n");
while (!feof(stdin))
{
fprintf("%s %.2f %.2f %.2f", iboy.name, iboy.scoremore.score1,
iboy.scoremore.score2, iboy.scoremore.score3);
scanf("%s %.1f", iboy.name, iboy.scoremore.score1, iboy.scoremore.score2,
iboy.scoremore.score3);
}
fclose(fp);
return 0;
}
想问一下,我这段代码,运行的时候有点问题。好像不能达到题目的要求,该怎么解决