问题描述
我想创建一个文件,如果它不存在,并且需要在附加模式下打开它。
so fopen a +是否可用于创建和附加文件?
帮帮我。
提前致谢。
Hi,
I want to create a file if its not exist and nees to open it in append mode.
so fopen with "a+" works for creation and appending a file?
Help me out.
Thanks in advance.
推荐答案
fopen用a +用于创建和附加文件
fopen with "a+" works for creation and appending a file
是的!
a +:打开文件进行阅读和追加。所有写入操作都在文件末尾执行,以保护以前的内容被覆盖。您可以将内部指针重新定位(fseek,倒带)到文件中的任何位置以进行读取,但写入操作会将其移回文件末尾。如果文件不存在,则创建该文件。
Yes!
"a+": Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.
这篇关于文件附加在C中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!