#include <iostream>
#include <fstream>
using namespace std;
int main()
{
const char *filename = "t.txt";
ofstream ofile;
ifstream ifile;
//write
ofile.open(filename);
ofile << "111111111111" << endl;
ofile << "222222222222" << endl;
ofile.close();
//read
string str;
ifile.open(filename);
while(ifile >> str)
cout << str << endl;
ifile.close();
return 0;
}
Sample of C++ read/write a text file
最新推荐文章于 2022-08-13 09:31:39 发布