hi, I have a code here that is reading two input files and creating one output file. What i am having trouble with is I don't know how to format the output file.
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
/* Read line by line and save to output file */
while((!in_stream.eof() && (!in_stream1.eof() )
{
getline(in_stream, name);
getline(in_stream1, score);
out_stream << name << " " << score <<endl;
}
SamuelAdams' suggestion has a typo (I think) as it is testing the EOF for the same file twice - though it would definitely be better to name your input streams a little more distinctly than in_stream and in_stream1.
Just as a suggestion for developing a code:
- in the initial test stages keep your input files small: not 20+ items
- while testing, write to cout first and only once working recode it to output to a file