Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File Merging in C++
#9
Code:
do
{
    ReadValue (inFA, A, successA);            //Read the value of file A.
    if(successA)
    {
        ReadValue (inFB, B, successB);        //Read the value of file B if the first was successfully read.
        if(successB)                            
        {
            //I WANT TO LOOP HERE.
            if(A < B)                //Check if the value of file A read is greater than the value of file B.
            {                                    
                WriteValue (outF, A);        //Write the value of file A if smaller than that of file B.
                ReadValue (inFA, A, successA);    //Read next value in file A.
            }
            else
            {
                WriteValue (outF, B);        //Write the value of file B if smaller than that of file A.
                ReadValue (inFB, B, successB);    //Read next value in file B.
            }
            //END LOOP HERE IF ONE OF THE SUCCESSES FAILS.
        }
        else
        {
            WriteValue (outF, A);            //If nothing in file B is read, print only file A's value.
        }
    }
    else
    {
        ReadValue (inFB, B, successB);
        if(successB)
        {
            WriteValue(outF, B);
        }
    }
}while (successA || successB);

Problem here: If I place a while loop containing (successA && success B) in the area I want to place a loop in, I get an infinite loop. But it shouldn't do that if one of the functions eventually fails reading a value... right?
Reply


Messages In This Thread
File Merging in C++ - by MariettaRC - 2013-09-27, 06:37 AM
File Merging in C++ - by SaptaZapta - 2013-09-27, 07:41 AM
File Merging in C++ - by MariettaRC - 2013-09-27, 07:59 AM
File Merging in C++ - by MariettaRC - 2013-09-27, 11:38 AM
File Merging in C++ - by SaptaZapta - 2013-09-27, 11:43 AM
File Merging in C++ - by MariettaRC - 2013-09-27, 11:53 AM
File Merging in C++ - by Dusk - 2013-09-27, 11:55 AM
File Merging in C++ - by SaptaZapta - 2013-09-27, 12:07 PM
File Merging in C++ - by MariettaRC - 2013-09-27, 01:52 PM
File Merging in C++ - by SaptaZapta - 2013-09-27, 02:00 PM
File Merging in C++ - by MariettaRC - 2013-09-27, 02:02 PM
File Merging in C++ - by MariettaRC - 2013-09-28, 02:31 PM
File Merging in C++ - by SaptaZapta - 2013-09-28, 03:23 PM
File Merging in C++ - by Dusk - 2013-09-28, 03:23 PM
File Merging in C++ - by MariettaRC - 2013-09-28, 03:30 PM
File Merging in C++ - by SaptaZapta - 2013-09-28, 03:38 PM
File Merging in C++ - by MariettaRC - 2013-09-28, 03:47 PM
File Merging in C++ - by Dusk - 2013-09-28, 03:51 PM
File Merging in C++ - by SaptaZapta - 2013-09-28, 03:56 PM
File Merging in C++ - by MariettaRC - 2013-09-28, 04:02 PM
File Merging in C++ - by SaptaZapta - 2013-09-28, 04:13 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)