我们可以在一个函数中同时使用输入文件的元素,同时将结果写入输出文件吗?
while语句内部是真的吗?
void solve(string inputFileName, string outputFileName)
{
//declaring variables
string filename = inputFileName;
//Open a stream for the input file
ifstream inputFile;
inputFile.open( filename.c_str(), ios_base::in );
//open a stream for output file
outputfile = outputFileName;
ofstream outputFile;
outputFile.open(outputfile.c_str(), ios_base::out);
while(!inputFile.eof())
{
inputFile >> number; //Read an integer from the file stream
outputFile << number*100 << "\n"
// do something
}
//close the input file stream
inputFile.close();
//close output file stream
outputFile.close();
}