如何使用fstream fstream :: app flag附加到文件似乎不起作用
所以这就是我所做的
#include <fstream>
fstream outfile;
//outfile.open("/tmp/debug.txt" ); // works, simply for writing
outfile.open("/tmp/debug.txt", fstream::app ); // does nothing
outfile << "START" << endl;
outfile.close();
i simply want to write (append) to a logfile. I looked it up here:
http://www.cplusplus.com/reference/iostream/fstream/open/
so this is what i did
#include <fstream>
fstream outfile;
//outfile.open("/tmp/debug.txt" ); // works, simply for writing
outfile.open("/tmp/debug.txt", fstream::app ); // does nothing
outfile << "START" << endl;
outfile.close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
fstream :: app | fstream :: out
而不是fstream :: app
。App
不用指定OUT
是没有意义的(人们可以认为它应该暗示out
,但事实并非如此)。fstream::app|fstream::out
instead offstream::app
.app
doesn't make sense without specifyingout
(one could think it should have impliedout
, but it doesn't).