c++feof问题
#include<stdio.h>int main()
{
FILE *p;
int sum,a=0;
p=fopen("Int_Data.dat","a+");
rewind(p);
while(!feof(p))
{
fscanf(p,"%d",&sum);
if(feof(p))
break;
printf("%d\n",sum);
a=a+sum;
}
printf("%d\n",a);
fseek(p,0L,SEEK_END);
fprintf(p,"%d",a);
if(fclose(p)){
printf("Can not close the file!");
exit(0);
}
}
dat文件中是1020304050,
为什么打印出来是
10
20
30
40
100
啊
https://blog.csdn.net/sinat_36082782/article/details/99771664 六小鸭 发表于 2020-3-24 11:32
https://blog.csdn.net/sinat_36082782/article/details/99771664
谢谢您的回答,但是我的程序是少了不是多了
页:
[1]