#include #include #include using namespace std; int main() { // open file for input //ifstream fin("24md.txt"); 1 way to do it string filename = "24md.txt"; ifstream fin; fin.open(filename.c_str()); int count = 0; string str; while (fin >> str) { // if it's a town, count it! if (str == "town") { count++; } } // output answer cout << "number of towns: " << count << endl; return 0; }