Why don't you put all of the data to be written into a std::stringstream ( http://cplusplus.com/reference/iostream/stringstream/ ) and then have a function that takes a filename to write to and the data to put into it.
That would be because I have not gotten to std::stringstream yet.
I am going with what I know, and practicing this until I have a good handle on it.
Also, it isn't using iostream for the most part. This program reads a file, and outputs to four other files depending on the data. The data also isn't just a string but also numbers.
So playing with this I came up this an Idea to use arrays such as outFile[4], and patho[4] to create, sort, and close my open files. In theory it would cut down on the amount of code I have up above. Then just use loops to rotate through my four sets.
1 2 3 4 5 6 7 8 9 10 11 12
string patho(i)
{
string temp="patho", a;
a = i;
strncpy(temp, a)
return temp;
};
ofstream outFile[i];
for (int i = 0; i < 4; i++)
outFile[i].open(patho(i));
I'm not a 100% sure on this but I think this may work.