Say I have the following:
FILE *fp1 = fopen("file.txt", "w");
fprintf(fp1,"%i\n",counter);
When I run my program, it writes the counter to the file. But when I run the program again and end up with a different counter, instead of writing that counter below the first one, it just replaces the first one. Is there a way to make it not just replace whats already in the file each time I run the program?
将文件访问模式设置为"a"
(附加),如下所示:
FILE *fp1 = fopen("file.txt", "a");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.