简单方式:
1 #include "stdafx.h"
2 #include <iostream>
3 #include <iomanip>
4 #include <fstream>
5
6 using namespace std;
7
8 void write()
9 {
10 ofstream out("C:\\Users\\hhx\\Desktop\\b.txt",ios::app);
11 if(!out){
12 cout << "Unable to open otfile";
13 exit(1);
14
15 }
16 printf("writting data into file C:\\Users\\hhx\\Desktop\\b.txt\n");
17 out<<"hello,"<<endl<<"world."<<endl;
18 out.close();
19 }
参考:http://blog.csdn.net/qingcaichongchong/article/details/8217526
原文链接: https://www.cnblogs.com/aaronhoo/p/5436731.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/232518
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!