#include #include #include // The file created by the previous program has a bunch of lines // that all look like this // January has 31 days. // // the "has" and "days." are useless, but they are in the file, // so we have to read them, but we don't have to use them. void main() { ifstream fin("months.txt"); if (fin.fail()) cout << "Error! I can't read the file.\n"; while (true) { string month_name, useless_has, useless_days; int month_length; fin >> month_name >> useless_has >> month_length >> useless_days; if (fin.fail()) // always check AFTER attempting to read. break; cout << month_name << ": " << month_length << "\n"; } cout << "Done\n"; }