C ++:ios :: app在fstream中不需要ios :: out [英] C++: ios::app doesnt need ios::out in fstream
问题描述
我在另一天用文件流对象中的标志进行测试
我这样做了。
fstream binf(h.txt,ios :: app);
binf<< 嘿;
使用fstream,因为我没有使用 ios :: out
我注意到输出操作使用 ios :: app > code>只有,但如果我使用任何其他标志不
ios :: out
它不工作
任何人告诉我为什么我只能使用 ios :: app
而不输出 ios :: out
使用 app code>。
标准规定 app
和 out | app
具有相同的结果,相当于在模式a
中的C fopen。
i was testing with flags in file stream objects the other day
And i did this.
fstream binf("h.txt", ios::app);
binf << "hey";
With fstream since i didnt use ios::out
, the output operation shouldnt have worked , but it does work
I noticed that the the output operation works with ios::app
only but if i use any other flag without ios::out
it doesnt work
Can anyone tell me why I was able to output to the file while using only ios::app
without ios::out
Using app
implies out
.
The standard specifies that app
and out|app
have the same result, equivalent to C fopen in mode "a"
.
这篇关于C ++:ios :: app在fstream中不需要ios :: out的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!