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();

 

posted @ 2018-10-28 19:59  ISGuXing  阅读(165)  评论(0编辑  收藏  举报