< previous page page_617 next page >

Page 617
    return 0;
}

//******************************************************************

void ReadFirstList(
           /* out */   int       firstList[],   // Filled first list
           /* out */   int&      length,        // Number of values
           /* inout */ ifstream& dataFile )     // Input file

// Reads the first list from the data file
// and counts the number of values in the list

// Precondition:
//     dataFile has been successfully opened for input
//  && The no. of input values in the first list <= MAX_NUMBER
// Postcondition:
//     length == number of input values in the first list
//  && firstList[0..length-1] contain the input values

{
    int counter;    // Index variable
    int number;     // Variable used for reading

    counter = 0;
    dataFile >> number;
    while (number >= 0)
    {

            // Invariant (prior to test):
            //     firstList[0..counter-1] contain the
            //     first "counter" input values
            //  && All previous values of number were >= 0

        firstList[counter] = number;
        counter++;
        dataFile >> number;
    }
    length = counter;
}

//******************************************************************

void CompareLists(
         /* inout */ Boolean&  allOK,         // True if lists match
         /* in */    const int firstList[],   // 1st list of numbers
         /* in */    int       length,        // Length of 1st list
         /* inout */ ifstream& dataFile    )  // Input file

 
< previous page page_617 next page >