2013-09-27, 02:00 PM
MariaColette Wrote: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.
}
}
}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?
Right, the loop should not be infinite.
If it seems to be running forever, try making WriteValue output the numbers to cout (as well as outF) so you can see how the program is progressing and where it's bogging down.

