各位大神,帮我看一下格式化输入跟输出的不一样?
#include <stdio.h>#include "string.h"
void screentofile()
{
char a[24]="外框";
int b=68;
char ch;
FILE *fp=fopen("F:\\微云同步盘\\c\\series.txt","w");
//格式化输出
fprintf(fp,"%s,%d",a,b);
fclose(fp); //关闭文件a,有打开就要有关闭
printf("\n\n\t写入成功...\n");
}
void fieltoscreen()
{
char a[24];
int b;
FILE *fp=fopen("F:\\微云同步盘\\c\\series.txt","r");
char ch;
while((ch=getc (fp)) != EOF) //逐行读取fp所指向文件中的内容
{
fscanf(fp,"%s,%d\n",a,b); //格式化输入
printf("%s,%d\n",a,b);
}
fclose(fp); //关闭文件a,有打开就要有关闭
}
int main(int argc, char *argv[])
{
screentofile();
fieltoscreen();
getch();
return 0;
}