#include #include #include using namespace std; typedef map word_count_map; // Unique word counter command int main(int argc, char* argv[]) { for ( int i = 1; i < argc; ++i ) { ifstream source( argv[i] ); if ( ! source ) { cerr << "Could not open " << argv[i] << endl; return 2; } string word; word_count_map countof; while ( source >> word ) ++countof[word]; for ( word_count_map::const_iterator itr = countof.begin(); itr != countof.end(); ++itr) cout << itr->first << ": " << itr->second << endl; source.close(); } return 0; }