您的位置:首页 > 编程语言 > C语言/C++

chapter17test4

2015-07-11 16:50 211 查看
#include<iostream>

#include<fstream>

#include<string>

int just(char);

int main()  //这个程序是参考别人的,这里用的string temp很好,刚开始我准备用char,但是没有走通。

{               //另外,fin.good()和fin.eof()也好。
using namespace std;
ifstream fin1("fin1.txt");
ifstream fin2("fin2.txt");
ofstream fout("fout.txt");
string temp;
while (fin1.good()&&fin2.good())
{
getline(fin1,temp);
fout << temp;
fout << ' ';
getline(fin2, temp);
fout << temp;
fout << endl;
}
if (fin1.good() && fin2.eof())
{
getline(fin1, temp);
fout << temp;
}
if (fin1.eof() && fin2.good())
{
getline(fin2, temp);
fout << temp;
}
fin1.close(); fin2.close(); fout.close();
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c++