#include
#include
int main()
{
FILE *fp;
int n,sum = 0;
if((fp = fopen("n.txt","r")) == NULL)
{
printf("Cannot open the file!");
exit(0);
}
while(fscanf(fp,"%d",&n) == EOF)
{
sum = sum + n;
fscanf(fp,"%d ",&n);
}
fprintf(fp,"%d ",sum);
fclose(fp);
return 0;
}
将文件中的数据累加的程序,无法实现其功能,请高手帮忙改错!!!
谢谢了哈
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|