// count.cpp -- count characters in a list of files
#include <iostream>
using namespace std;
#include <fstream>
#include <cstdlib>          // or stdlib.h
// #include <console.h>     // for Macintosh
int main(int argc, char * argv[])
{
    // argc = ccommand(&argv);      // for Macintosh
    if (argc == 1)          // quit if no arguments
    {
    cerr << "Usage: " << argv[0] << " filename[s]\n";
    exit(1);
    }                           

    ifstream fin;           // open stream
    long count;
    long total = 0;
    char ch;

    for (int file = 1; file < argc; file++)
    {
    fin.open(argv[file]);   // connect stream to argv[file]
    count = 0;
    while (fin.get(ch))
        count++;
    cout << count << " characters in " << argv[file] << "\n";
    total += count;
    fin.clear();            // needed for some implementations
    fin.close();            // disconnect file
    }
    cout << total << " characters in all files\n";

    return 0;
}
