编写程序,功能是从键盘依次输入1个整数1234、1个字符a、1个实数5.6,用fprintf函数写入文件int.txt中。在试题文件夹中查看文件int.txt中的内容。

#include <stdio.h>
#include <stdlib.h>
int main ()
{
FILE*fp;
int a;
char b;
float c;
scanf ("%d, %c, %f", &a, &b, &c);
if((fp=fopen("int.txt","w+") )==NULL)
{
printf("cannot open file\n");
exit(0);
}
fprintf(fp,"%d, %c, %f",a,b,c);
rewind(fp);
fclose(fp);
return 0;
}

然而scanf函数运行完就结束了,打不开文件夹

scanf无法进行正常文件写入操作,文件输入输出流中写入文件只有 fscanf, fputc,fputs 三个函数
如有帮助,请点个采纳捏~