首页 > 编程语言 >c++读写文件

c++读写文件

时间:2022-10-12 14:55:47浏览次数:68  
标签:文件 include buf 读写 ios c++ test txt open

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

using namespace std;

int main() {

ofstream f;
f.open("test.txt",ios::out);
f << "aaaaaa" << endl;


ifstream f;
f.open("test.txt",ios::in);
string buf;
while (getline(f, buf)) {
cout << buf << endl;
}


f.close();
system("pause");
return 0;
}

 

标签:文件,include,buf,读写,ios,c++,test,txt,open
From: https://www.cnblogs.com/chentianyu/p/16784530.html

相关文章