Question: Can someone make this program run multiple times before closing, like let me search multiple movies without exiting the console or going to the bottom
Can someone make this program run multiple times before closing, like let me search multiple movies without exiting the console or going to the bottom of the list. Thank you.
This is C++
// movies.txt (input file)
Avengers 2019 2.79 Avatar 2009 2.79 Titanic 1997 2.19 Star Wars:The Force Awakens 2015 2.68 Avengers: Infinity War 2018 2.04 The Lion King 2019 1.75
======================================
#include
using namespace std;
// Creating Structure struct Movie { string name; int releasedYear; double revenue; };
// Function Declarations int storeMoviesArray(string filename,Movie movies[],int SIZE); void sortMoviesTitle(Movie movies[],int SIZE); void printMoviesArray(Movie movies[],int SIZE); int main() { // Declaring variables string filename="movies.txt"; const int SIZE=20; int count=0,index=-1; string searchName; // Creating Struct Array Movie movies[SIZE]; count=storeMoviesArray(filename,movies,SIZE); sortMoviesTitle(movies,count); //Getting the input entered by the user cout<<" Enter a movie name to search :"; getline(cin,searchName); for(int i=0;i // This function will read the data from the file and Populate into Struct Array int storeMoviesArray(string filename,Movie movies[],int SIZE) { int count=0; ifstream dataIn; string str; dataIn.open(filename.c_str()); /* * checking whether the file name is valid or not */ if(dataIn.fail()) { cout<<"** File Not Found **"< } void printMoviesArray(Movie movies[],int SIZE) { cout<<"Displaying the List of Movies :"<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
