gpt4 book ai didi

c - 追加 "a+"是否自动将光标置于末尾

转载 作者:行者123 更新时间:2023-11-30 21:48:10 28 4
gpt4 key购买 nike

我想用 c 打开一个文件,然后向其中添加一些内容并关闭它。我只是想知道 fopen 中的 a+ 自动导航到文件的最后一个字符。

最佳答案

是的。

为什么不尝试一下,或者阅读一下手册呢?

这里是:

   r      Open text file for reading.  The stream is positioned at the beginning of the file.

r+ Open for reading and writing. The stream is positioned at the beginning of the file.

w Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the
file.

w+ Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is
positioned at the beginning of the file.

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 - 追加 "a+"是否自动将光标置于末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23087586/

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