#include <fstream>
#include <iostream>
#include <map>
#include <set>

using namespace std;

string<char> dictionary("/usr/share/dict/words");

int main(int argc, char** argv) {

        set<string> dict;
        map<string, int> count;
        ifstream d;
        d.open(dictionary.c_str());
        string word;
        while (d >> word) {
                dict.insert(word);
        }

        ifstream w(argv[1]);
        while (w >> word) {
                if (dict.find(word) != dict.end()) {
                        count[word]++;
                }
        }

        for (map<string, int>::iterator i = count.begin();
             i != count.end();
             i++)
        {
                cout << (*i).first << ' ' << (*i).second << endl;
        }
        return 0;
};



-- 
Respectfully,

Nicholas Leippe
Sales Team Automation, LLC
1335 West 1650 North, Suite C
Springville, UT  84663 +1 801.853.4090
http://www.salesteamautomation.com

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to