如何在fstream文件之间切换

如何在fstream文件之间切换

本文介绍了如何在fstream文件之间切换,而不关闭它们(同时输出文件) - C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个C ++问题,我无法通过在线浏览解决。这是我的代码(提取):I have a little C++ issue that I couldn't solve by browsing online. Here is my code (extracted): 当您切换 c> $ 只有 ostream 对象,我们可以切换 的缓冲区files get automatically closed when the buffers map goes out of scope.you might need to add explicit flushes when switching rdbuf() like this, if you don't end your lines with an implicit std::flush (like with std::endl).dummy only exists to have an ostream object that we can switch the buffer of我使用以下输入测试了这个:I tested this with the following input:Header Row #1Header Row #2Jack,1,some dataJill,2,some more dataJack,3,not reopening :)Jill,4,jill still receiving outputRomeo,5,someone else reporting现在,我得到以下输出: 住在ColiruNow, I got the following output: see it live at Colirug++ -std=c++11 -Wall -g test.cpp -o test==> Jack.csv <==Jack,1,some dataJack,3,not reopening :)==> Jill.csv <==Jill,2,some more dataJill,4,jill still receiving output==> Romeo.csv <==Romeo,5,someone else reporting 这篇关于如何在fstream文件之间切换,而不关闭它们(同时输出文件) - C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 19:08