如果文件已经存在,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 +将在文件中追加新的内容