#include #include #include using namespace std; string convert(string s) { string result = ""; for (int i = 0; i < s.length(); i += 1) { char c = s[i]; if (c >= 'a' && c <= 'z') result += c; else if (c >= 'A' && c <= 'Z') result += c + ('a' - 'A'); } return result; } int main() { ifstream in("/home/www/text/barrie/peterpan"); if (in.fail()) { cout << "Can't read home/www/text/barrie/peterpan\n"; exit(1); } const int max = 47800; string words[max]; int counts[max]; for (int i = 0; i < max; i += 1) { words[i] = ""; counts[i] = 0; } // We only got this far in the conversion by the end of class. while (true) { string word; in >> word; if (in.fail()) break; word = convert(word); if (word == "the") the += 1; } in.close(); cout << "\"The\" appeared " << the << " times\n"; }