944,196 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1663
  • C RSS
Feb 12th, 2005
0

Can anyone tell me how to print to alternate files?

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
tat2dlady is offline Offline
32 posts
since Jan 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Recursive functions???
Next Thread in C Forum Timeline: Exporting data into Excel





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC