运行环境:windows7,Dev-C++4.9.9.2
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fp;
int a,b;
if((fp=fopen("E:\\task.txt","r"))==NULL)
{
printf("不能打开文件!\n");
while(1);
exit(0);
}
文件task.txt的内容:
1,30
2,20
3,40
4,20
int j;
while(!feof(fp))
{ j=feof(fp);
printf("j=%d\n",j);
fscanf(fp,"%d,%d",&a,&b);
printf("%d,%d\n",a,b);
}
fclose(fp);
while(1);
return 0;
}
慕田峪9158850
相关分类