我的代码:
int main()
struct student
{
int num;
char name[50];
float maths;
float english;
float cxsj;
float chxgl;
float dqxtkx;
float average;
};
printf("提示:学生总数不得超过1000。\n");
int N;
printf("学生总数为:");
scanf_s("%d", &N);
printf("\n\n");
struct student stu[1000]{};
printf("读入学生成绩:\n\n");
const char* path1 = "C:\\Users\\Desktop\\上课\\大作业\\学生成绩文档.txt";
FILE* p1 = NULL;
int a1 = fopen_s(&p1, path1, "wb+");
student blank1 = { 0," ",0,0,0,0,0,0 };
fwrite(&blank1, sizeof(stu), N, p1);
fclose(p1);
printf("\n以下是已读入的学生成绩:\n\n");
FILE* p11 = NULL;
int a11 = fopen_s(&p11, path1, "rb");
while (feof(p11) == 0)
{
student stu1;
fread(&stu1, sizeof(struct student), 1, p11);
printf("%d %s %f %f %f %f %f %f\n", stu1.num, stu1.name, stu1.maths, stu1.english, stu1.dqxtkx, stu1.cxsj, stu1.chxgl, stu1.average);
}
fclose(p11);
return 1;
}
我想要将四个{0, ,0等等}打印到文档里面,为什么读出来是乱码?我应该怎么改?