My code seems alright to me. Then when I run it, it doesnt let me get input for the title for movie 2. It skips straight to director.
#include <iostream>
#include <string>
using namespace std;
void display(string,string,int,int);
struct MovieData{
string title,
director;
int yearReleased,
runningTime;
};
int main(int argc, char** argv) {
MovieData movie1;
MovieData movie2;
cout<<"Enter the following information for movie 1\n"<<endl;
cout<<"Title: ";
getline(cin, movie1.title);
cout<<"Director: ";
getline(cin, movie1.director);
cout<<"Year Released: ";
cin>>movie1.yearReleased;
cout<<"Run time (min): ";
cin>>movie1.runningTime;
cout<<"\nEnter the following information for movie 2 \n"<<endl;
cout<<"Title: ";
getline(cin, movie2.title);
cout<<"Director: ";
getline(cin, movie2.director);
cout<<"Year Released: ";
cin>>movie2.yearReleased;
cout<<"Run time (min): ";
cin>>movie2.runningTime;
display(movie1.title, movie1.director, movie1.yearReleased, movie1.runningTime);
display(movie2.title, movie2.director, movie2.yearReleased, movie2.runningTime);
system("PAUSE");
return 0;
}
void display(string title, string director, int yearOut, int runTime){
cout<<"Movie Information"<<endl;
cout<<"----------------"<<endl;
cout<<"Title: "<<title<<endl;
cout<<"Director: "<<director<<endl;
cout<<"Year released: "<<yearOut<<endl;
cout<<"Running time: "<<runTime<<endl;
}
Last edited on