#include #include #include using namespace std; int main() { ifstream fi; fi.open("peterpan.txt"); if (fi.fail()) { cout << "Couldn't open the file\n"; exit(1); } int thecount = 0, wordcount = 0; while (true) { string s; fi >> s; if (fi.fail()) break; wordcount += 1; if (s == "the" || s == "The") thecount += 1; } fi.close(); cout << "There were " << wordcount << " words,\n"; cout << "'the' appeared " << thecount << " times.\n"; }