#include <iostream.h>
#include <fstream.h>
#include <string>
#include <stdlib.h>

// count # of lines in input file
// Owen Astrachan, written: 7/11/94

int main()
{
    string filename;
    ifstream input;
    int numLines = 0;
    int numChars = 0;
    string s;                              // line entered by user
    
    cout << "enter name of input file: ";
    cin >> filename;

    input.open( filename.c_str() );

    if (input.fail() )
    {
        cout << "could not open file " << filename << endl;
        exit(1);
    }
    
    while (getline(input,s))
    {
        numLines += 1;
        numChars += s.length();
    }

    cout << "number of lines = " << numLines
         << ", number of characters = " << numChars << endl;
    return 0;
}

