c++读写文件
#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;
}
浙公网安备 33010602011771号