哪位高人帮忙解决一下关于用fscanf函数从.txt文件中读取数据的问题
程序如下:#include<stdio.h>intmain(){FILE*fp;inti,data[8];fp=fopen("int.txt","w");printf("...
程序如下:
#include <stdio.h>
int main()
{
FILE *fp;
int i, data[8];
fp=fopen("int.txt","w");
printf("Now display read date!\n");
if((fp=fopen("int.txt","r"))==NULL) return 1;
for(i=0;i<8;i++){
fscanf(fp, "%d,", &data[i]);
printf("%d:%-10d\n",i+1,data[i]);
}
fclose(fp);
return 0;
} 展开
#include <stdio.h>
int main()
{
FILE *fp;
int i, data[8];
fp=fopen("int.txt","w");
printf("Now display read date!\n");
if((fp=fopen("int.txt","r"))==NULL) return 1;
for(i=0;i<8;i++){
fscanf(fp, "%d,", &data[i]);
printf("%d:%-10d\n",i+1,data[i]);
}
fclose(fp);
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询