#include #include #include "wordlist.h" using namespace std; int main(int argc, char ** argv){ if(argc < 2){ cout << "Usage: " << argv[0] << " filename\n"; return 1; } ifstream fin; fin.open("/usr/share/dict/american-english"); string cword; WordList spellcheck; while(fin >> cword){ for(int letter = 0; letter < cword.length(); letter++) cword[letter] = tolower(cword[letter]); spellcheck.add(cword); } ifstream check_in; check_in.open(argv[1]); while(check_in >> cword){ while(cword[cword.length() - 1] == '.' || cword[cword.length() - 1] == ',') cword.erase(cword.length() - 1, 1); for(int letter = 0; letter < cword.length(); letter++) cword[letter] = tolower(cword[letter]); if(spellcheck.find(cword)) cout << cword << " is in the dictionary\n"; else cout << cword << " is NOT in the dictionary\n"; } return 0; }