#include #include #include using namespace std; // fix tidies up a string, removing anything that isn't // a letter, and converting capital letters to little ones. string fix(string s) { string result = ""; for (int i=0; i='a' && c<='z') result += c; else if (c>='A' && c<='Z') result += c + ('a'-'A'); } return result; } // if you #include it will give you a whole load // of utility functions that let you write things like // if (isupper(c)) // instead of // if (c>='A' && c<='Z') // and // tolower(c) // instead of // c + ('a'-'A') // for a list of them all, type "man ctype". For details // of a specific one, type e.g. "man isupper" on a unix system. bool is_word_ok(string list[], int size, string w) { for (int i=0; i> s; if (wl.fail()) break; if (numw>=maxnum) { cout << "too many words\n"; break; } s = fix(s); if (s != "") { list[numw] = s; numw += 1; } } wl.close(); return numw; } int main() { const int arraysize = 111000; string wordlist[arraysize]; int wlsize = read_word_list(wordlist, arraysize); ifstream story("39steps.txt"); if (story.fail()) { cout << "Can't read the story\n"; exit(1); } while (true) { string q; story >> q; if (story.fail()) break; q = fix(q); if (q == "") continue; if (! is_word_ok(wordlist, wlsize, q)) { cout << q << " is " << "NOT OK\n"; } } story.close(); cout << "Done\n"; }