c++文件流

1、逐行读入

 1 ifstream infile;
 2     ofstream outfile;
 3     infile.open("in.txt");
 4     outfile.open("out.txt");
 5     assert(infile.is_open());  //报错
 6     string s,p;
 7     while(getline(infile,s)){
 8         getline(infile,p);
 9         cout<<s<<endl;
10         outfile<<s<<endl;
11         cout<<p<<endl;
12         outfile<<p<<endl;
13 
14     }
15     infile.close();
16     outfile.close();
原文地址:https://www.cnblogs.com/ISGuXing/p/9866828.html