954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can anyone tell me how to print to alternate files?

I have a program for a 5-way sort merge. I can get the program to read from the original file of 1,000,000 records and write them to 5 tempoary files (File0 thru File4). Then, I am suppose to close the temp files (Files 0 - 4) and open them as input, and open 5 more temp files (File 5 thru File 9). I cannot get the Files 0 - 4 to print to Files 5 - 9. Here is part of my code, as it is a little long. How do you get the % operator to print to Files 5 - 9? It works fine for Files 0 - 4.

InputCounter = 0;
OutputCounter = 5;
int NumOfPasses = 0;
FileSize = ClumpSize * NumOfFiles;

while (NumOfFiles < 5)
{
while (LoopCount < FileSize)
{
for (j = 0; j < ClumpSize; j++)
{
F[InputCounter%5] >> Number;
ClumpArray[j] = Number;
} // end for

QuickSort(ClumpArray, 0, 999);

for (i = 0; i < ClumpSize; i++)
{
F[InputCounter%5] << setprecision(15);
F[InputCounter%5] << ClumpArray[i] << '\n';
} // end for

InputCounter ++;
OutputCounter++;
} // end while

NumOfFiles ++;
LoopCount++;
} // end while

Thanks for any input you may have.

tat2dlady
Light Poster
32 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You