c语言读取txt文件文件数据为空

2025-12-16 19:29:49
推荐回答(3个)
回答1:

//其中的in.txt就是你要读取数据的文件,当然把它和程序放在同一目录 ------------------------------------- #include <...

回答2:

FILE *fp;

char ch;

fp = fopen("yuangonghao 1.txt", "r");

if(fp!=NULL)

{

while((ch=fgetc(fp))!=EOF)

{

putchar(ch);

}

fclose(fp);

}

回答3:

char s[200];
int a,b,c;
fgets(fp,s);
fgets(fp,s);
for(int i=0;i<5;i++)
{fscanf(fp,"==%d%d",&a,&b);
printf("== %d %d\n",&a,&b);
}
fscanf(fp,"== 年/月/日: %d/%d/%d",&a,&b,&c);
printf("== 年/月/日: %d/%d/%d",a,b,c);