Can anyone tell me how to print to alternate files?

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2005
Posts: 31
Reputation: tat2dlady is an unknown quantity at this point 
Solved Threads: 0
tat2dlady tat2dlady is offline Offline
Light Poster

Can anyone tell me how to print to alternate files?

 
0
  #1
Feb 12th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC