#include #include #include #include #include using namespace std; class Actor { public: string name; map movies; map years; }; class Movie { public: string name; int year; map actors; }; class Year { public: int year; map movies; map actors; }; main(int argc, char **argv) { ifstream fin; int i, j; string s; int year; for (i = 1; i < argc; i++) { fin.open(argv[i]); if (fin.fail()) { cerr << "Problem opening " << argv[i] << endl; exit(1); } s = argv[i]; j = s.find(".txt"); if (j == string::npos) { cerr << "File does not have a .txt extension: " << s << endl; exit(1); } s.resize(j); for (j = 0; j < s.length(); j++) { if (s[j] == '-') s[j] = ' '; } fin >> year; if (fin.fail()) { cerr << "The first line of " << s << " should be the year\n"; exit(1); } cout << "Movie: " << s << ". Year: " << year << endl; getline(fin, s); while (!fin.fail()) { getline(fin, s); if (!fin.fail()) { j = s.find(" - "); if (j == string::npos) { cerr << "Actor specifications should be actor name '-' role name\n"; cerr << "S: " << s << endl; exit(1); } while (s[j] == ' ') j--; s.resize(j+1); cout << "Actor: " << s << endl; } } fin.close(); fin.clear(); } exit(0); }