Did a quick search but couldn't find anything on ostream and multiple files depending on data.
I'm pretty sure it's something very simple flying over my head, but I can't seem to get this to work. Basically what I want to do is write to a file depending on the data. If the student has a certain amount of credits they're written to one file, if they don't have this certain amount, they're written to another. Everything compiles fine, the first file even gets created (outfile1). I can't get the 2nd file to write though. Any help is greatly appreciated.
Here is a snippet.
for( int i = 0 ; i < numOfLines; i++)
{
inFile >> fname >> lname >> d >> n >> c;
x[i].setF(fname);
x[i].setL(lname);
x[i].setD(d);
x[i].setN(n);
x[i].setCredit(c);
if ( c >= 12)
{
x[i].printToFile(outFile1);
}
else
{
x[i].printToFile(outFile2);
}
}
ouFile1 and outFile two have already been opened.