作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我无法理解 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/
我是一名优秀的程序员,十分优秀!