std::ios::ate未实现追加写
时间: 2023-09-05 14:09:29 浏览: 174
引用\[2\]中提到,使用std::ios::ate打开文件时,文件指针会定位到文件末尾。然而,如果不配合std::ios::in模式,即只使用std::ios::ate和std::ios::out模式打开文件,会清空原文件。所以,std::ios::ate并不能实现追加写入的功能。如果想要实现追加写入,可以使用std::ios::app模式打开文件,这样写入的内容会被追加到文件末尾。
#### 引用[.reference_title]
- *1* [C++ 文件读写操作std::ofstream和std::ifstream](https://blog.csdn.net/block999123/article/details/121869208)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [ofstream之ios::ate,ios::app,ios::in,ios::out](https://blog.csdn.net/cabbage2008/article/details/53307409)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [std::ifstream是C++标准库中的一个输入文件流类,它提供了一组函数来读取文件中的数据](https://blog.csdn.net/m0_46661183/article/details/130769483)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文