FStream C ++自动换行 [英] FStream C++ automatic line addition

查看:401
本文介绍了FStream C ++自动换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个痛苦,做每个值之间的endline与OFSTREAM。
下面是一个例子:

It is a pain to do an endline between each value with OFSTREAM. Here's an example of what I've got:

    ofstream fout("~/xample.txt");
    fout << val1;
    fout << endl;
    fout << val2;

我想能够做,而是

    ofstream fout("xample.txt");
    fout << val1;
    fout << val2;

我不在乎如何存储文件,因为我将写一个配置向导。 p>

I don't care how the file is stored because I will write a configuration wizard anyways.

推荐答案

如果 fout< val1<< endl; 不能与你一起工作,你可以继承stream并创建自己的流,自动添加 endl 。但你也可以从消防栓喝水。

If fout << val1 << endl; does not work with you, you might be able to inherit ofstream and create your own stream that adds endl automatically. But also you can drink water from fire hydrant.

这篇关于FStream C ++自动换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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