文件输出问题,文件输出不停止
第一次提问,多谢回答!
这是一个文件输出问题,从两个文件读取并输出到另外一个文件。
为什么把getline(char*,int,char)函数的第二个参数掉输出就不停止呢?
getline(input,'\n')不是遇到'\n'就停止了吗
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream finFirst;
ifstream finSecond;
ofstream fout;
finFirst.open("inFirst.txt");
finSecond.open("inSecond.txt");
fout.open("out.txt");
char* strInput = new char[80];
while( !finFirst.eof() || !finSecond.eof() )
{
if( finSecond.eof() )
{
finFirst.getline( strInput, 80, '\n' );
fout << strInput << endl;
//finFirst.get( strInput );
}
else if( finFirst.eof() )
{
finSecond.getline( strInput, 80, '\n' );
fout << strInput << endl;
}
else
{
finFirst.getline( strInput, 80, '\n');
fout << strInput << " ";
finSecond.getline( strInput, 80, '\n' );
fout << strInput << endl;
}
}
finFirst.close();
finSecond.close();
fout.close();
system("pause");
return 0;
}