gpt4 book ai didi

c++ - fopen 函数中的 a 和 a+ 选项有什么区别?

转载 作者:太空狗 更新时间:2023-10-29 19:41:51 25 4
gpt4 key购买 nike

我无法理解 C fopen api 文档中对“a”和“a+”选项的描述。 “a+”中的选项是追加和更新。这里更新这个词是什么意思?

最佳答案

这是手册页 (man fopen) 的内容:

a

Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file.

a+

Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file.


这意味着:

获得+:指针最初位于文件的开头(用于读取),但是当尝试进行写操作时,它会移至文件的末尾。

关于c++ - fopen 函数中的 a 和 a+ 选项有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19874373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com