有人能告诉我为什么文件不变吗?当我使用rewind或fseek时,它可以工作,但在其他情况下就不行了。
在fgets之后使用fputs的标准方法是什么?文件指示器位于位置9,因此fputs必须在此位置之后写入,但它不做任何事情。
在文件中:
abcd efgh ijkl mnor在源代码中:
char c;
char str[15];
FILE *fp = fopen("d:\\data.txt","r+");
fgets(str, 10, fp);
// fseek(fp, 9, SEEK_SET);
// rewind(fp);
printf("%d\n", ftell(fp));
// ftel shows that it's in "9".
printf("%s", str);
fputs(str, fp);
// why its not working
fclose(fp);https://stackoverflow.com/questions/46152077
复制相似问题