而不是附加“abc”(从而最终得到一个充满 abcabcabc 的文件......),无论我运行多少次,我的文件只包含“abc”......我怎样才能附加?
#include <stdio.h>
#include <string.h>
int main(){
char strng[10];
strcpy(strng,"abc");
FILE *my_file;
my_file = fopen("myfile","a+");
if (my_file == NULL){ printf("problem\n");}
fwrite(strng, sizeof(strng), 1, my_file);
printf("appending %s\n",strng);
fclose(my_file);
}
Run Code Online (Sandbox Code Playgroud)