gpt4 book ai didi

c++ - 文件 IO 默认参数问题

转载 作者:行者123 更新时间:2023-11-30 02:10:29 25 4
gpt4 key购买 nike

打开文件时,文件的默认参数是什么?

fstream  a1;
ifstream b2;
ofstream c3;

a1.open("randFile.txt");
b2.open("randFile.txt");
c3.open("randFile.txt");

引用:http://www.cplusplus.com/reference/iostream/fstream/open/

最佳答案

文件流:

void open ( const char * filename,
ios_base::openmode mode = ios_base::in | ios_base::out );

因此默认情况下文件将同时打开用于输入和输出。

对于 ifstream 和 ofstream 默认值将相应地为只读和只写(检查 ifstreamofstream 的方法引用)

关于c++ - 文件 IO 默认参数问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4522604/

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