相关疑难解决方法(0)

使用C中的fputs写入文件

有人能告诉我为什么文件不会改变?它适用于我使用rewindfseek不使用的情况.

什么是使用fputs后的标准方式fgets.文件指示器位于第9位,因此fputs必须在此之后写入,但它不会执行任何操作.

在档案中:

abcd efgh ijkl mnor
Run Code Online (Sandbox Code Playgroud)

在源代码中:

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);
Run Code Online (Sandbox Code Playgroud)

c string file

18
推荐指数
2
解决办法
2989
查看次数

标签 统计

c ×1

file ×1

string ×1