C ++:ios :: app在fstream中不需要ios :: out [英] C++: ios::app doesnt need ios::out in fstream

查看:362
本文介绍了C ++:ios :: app在fstream中不需要ios :: out的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在另一天用文件流对象中的标志进行测试



我这样做了。

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆