如果文件已经存在,fopen 是创建文件还是更新文件?

Does fopen create file or update file if the file already exists?

如果文件已经存在,fopen() 是创建文件还是更新文件?

这取决于模式。如果您使用 r 或 r+ 它不会创建文件。如果您使用 w,w+,a,a+,x,X+,c,c+ 它将创建文件。

w 和 w+ 也将删除文件的所有内容并从头开始写入。 a 和 a+ 将在文件中追加新内容。