< previous page page_624 next page >

Page 624
            // Invariant (prior to test):
            //     For all previous values of inputChar,
            //     freqList contains the counts of characters
            //     that were found in charList

        ScanList(charList, length, inputChar, index, found);
        if (found)
            freqList[index]++;
        dataFile.get(inputChar);          // Don't skip whitespace
    }

    Print(freqList, charList, length);
    return 0;
}

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

void GetCharList( /* out */ char charList[],    // List of chars
                  /* out */ int& length     )   // Length of list

// Reads the list of characters from standard input
// until SENTINEL_CHAR is encountered

// Postcondition:
//     User has been prompted to enter the list of characters
//  && length == number of characters in the list
//  && charList[0..length-1] contain the input characters
// Note:
//     If the user enters more than MAX_LENGTH characters
//     or types duplicate characters, the effect of this
//     function is undefined
{
    int counter;    // Index variable
    char ch;        // Used for reading

    cout << "Please enter your list of characters." << endl
         << "Enter at most " <MAX_LENGTH < " characters," < endl
         << "and terminate the list with a pound sign (#)." < endl;
    counter = 0;
    cin.get(ch);
    while (ch != SENTINEL_CHAR)
{
            // Invariant (prior to test):
            //     charList[0..counter-1] contain the
            //       first "counter" input values
            //  && No previous value of ch was SENTINEL_CHAR

 
< previous page page_624 next page >