问题遇到的现象和发生背景
我用vs2022想从文件里读取信息
问题相关代码,请勿粘贴截图
void ReadDocument(PointNode &p)
{
FILE* fp;
errno_t fpp;
fpp=fopen_s(&fp,"student.txt", "r");
if (fpp != 0)
{
printf("文件打开失败!");
exit(1);
}
else
{
while (!feof(fp))
{
fscanf_s(fp, "%d",&p->stu.xuehao);
//fscanf_s(fp, "%s",s.name);
for(int i=0;i<N;i++)
{
fscanf_s(fp, "%lf", &p->stu.score[i]);
}
printf(" %d ",p->stu.xuehao);
for (int i = 0; i < N; i++)
{
printf("%.2f ", p->stu.score[i]);
}
printf("\n");
p->next = new Node;
p = p->next;
}
}
fclose(fp);
}
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
正确读入
tatic/image/mid/ask/703132834256182.png "#left")