Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- struct Movie
- {
- string name;
- string year;
- string genre;
- };
- void find_movies_time_frame(string first, string last, string arg)
- {
- Movie instance1;
- //step1
- ifstream data_store;
- //step2
- data_store.open("movie_database.txt");
- if (!data_store)
- {
- cout << "Error loading file\n";
- exit(0);
- }
- else
- {
- //step3
- while (!data_store.eof())
- {
- getline(data_store, instance1.name);
- getline(data_store, instance1.year);
- getline(data_store, instance1.genre);
- if (instance1.genre == arg && instance1.year >= first && instance1.year <= last)
- {
- cout << instance1.name << " " << instance1.year << endl;
- }
- }
- }
- //step4
- data_store.close();
- return;
- }
- int main()
- {
- const string genre = "Comedy";
- string year1, year2;
- cout << genre << " Movie Finder\n";
- cout << "Enter beginning year\n";
- cin >> year1;
- cout << "Enter ending year\n";
- cin >> year2;
- find_movies_time_frame(year1, year2, genre);
- return 0;
- }
Add Comment
Please, Sign In to add comment