首页 > 编程语言 > 详细

C++ 在文本文件后追加写入字符串

时间:2016-05-15 21:24:24      阅读:449      评论:0      收藏:0      [点我收藏+]

下面的代码起到这样一个作用:

如果有flow.txt文件,则打开该文件,在文件中继续写入字符串;

如果没有该文件,则创建该文件并写入。

 

#include<string>
#include<fstream>
#include <iostream>

 

std::ofstream file;
if (file.bad())
{
    std::cout << "cannot open file" << std::endl;;
}
file.open("flow.txt", std::ios::app);
file << flow << "\n";

C++ 在文本文件后追加写入字符串

原文:http://www.cnblogs.com/VVingerfly/p/5495892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!