大家帮忙看看 这个是哪里的错误 谢谢 运行最后几句话就错了 全是乱码
#include<stdio.h>#define N 1
struct
{
int num;
char name[20];
int score[4];
float avg;
}stu[10];
int main(void)
{
FILE *fp;
int i,m,n;
printf ("请输入您要的10个学生信息。\n");
for (i=0; i<=N; i++)
{
printf ("第%d个学生\n",i+1);
printf ("学号:\n");
scanf ("%d", &stu[i].num);
printf ("姓名:\n");
scanf ("%s", stu[i].name);
printf ("数学:\n");
scanf ("%d", &stu[i].score[0]);
printf ("外语:\n");
scanf ("%d", &stu[i].score[1]);
printf ("体育:\n");
scanf ("%d", &stu[i].score[2]);
printf ("C语言:\n");
scanf ("%d", &stu[i].score[3]);
stu[i].avg = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2] + stu[i].score[3])/4.0;
}
if( (fp = fopen("stud","w")) == NULL)
{
printf("文件不存在");
exit(-1);
}
printf ("您输入的学生信息如下:\n");
printf ("学号 姓名 数学 外语 体育 C语言 平均分");
for(m=0; m<N; m++)
{
fprintf (fp,"%d%s%d%d%d%d%d",&stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2], &stu[i].score[3],&stu[i].avg);
}
fclose(fp);
fp = fopen("stud","r");
for (n=0; n<=N; n++)
{
fscanf (fp,"%d%s%d%d%d%d%d",&stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2], &stu[i].score[3],&stu[i].avg);
printf ("%d\t%s\t%d\t%d\t%d\t%d\t%d",&stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2], &stu[i].score[3],&stu[i].avg);
printf ("\n");
}
return 0;
}