< previous page page_483 next page >

Page 483
    cout.setf(ios::fixed, ios::floatfield);   // Set up floating pt.
    cout.setf(ios::showpoint);                //   output format
    cout << setprecision(2);

    inFile.open(my file.txt);
    if ( !inFile )
    {

        cout << ** Can't open input file ** << endl;
        return 1;
    }

    inFile. get (inputChar);
    while (inFile)
    {
          // Invariant (prior to test):
          //     All previous values of inputChar
          //     have been read, echoed, and categorized

       cout << inputChar;
       IncrementProperCounter(upperCount, lowerCount, digitCount,
                              blankCount, puncCount,
                              leftOverCount, inputChar);
       inFile.get(inputChar);
    }
    CalculateAndPrint(upperCount, lowerCount, digitCount,
                      blankCount, puncCount, leftOverCount);
    return 0;
}

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

void IncrementProperCounter
    ( /* inout */ int& upperCount,      // Counter
      /* inout */ int& lowerCount,      // Counter
      /* inout */ int& digitCount,      // Counter
      /* inout */ int& blankCount,      // Counter
      /* inout */ int& puncCount,       // Counter
      /* inout */ int& leftOverCount,   // Counter
      /* in */    char ch                )  // Current character

// Increments the proper counter for a given character, ch

 
< previous page page_483 next page >