基础系列
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream a;
a.open("1.txt",ios::out);
a<<"i'm chinese,i love china"<<endl;
a<<"and i love USA too."<<endl;
a<<"1111111111111111"<<endl;
a.close();
ifstream b;
b.open("1.txt",ios::in);
string str;
while(getline(b,str)){//按行读取
cout<<str<<endl;
}
return 0;
}
结果: