I have this bit of code over here. Basically, it asks the userto enter informati
ID: 3614830 • Letter: I
Question
I have this bit of code over here. Basically, it asks the userto enter information about a movie. I need it to do it for twomovies. The code works just fine for the first movie, using theloop. But when it loops to the second movie, it skips the firstquestion which is the title of the movie, and just goes to thedirector. I dont know what I'm doing wrong.Lifesaver rating to anyone that can help me fix this.
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }
I have this bit of code over here. Basically, it asks the userto enter information about a movie. I need it to do it for twomovies. The code works just fine for the first movie, using theloop. But when it loops to the second movie, it skips the firstquestion which is the title of the movie, and just goes to thedirector. I dont know what I'm doing wrong.
Lifesaver rating to anyone that can help me fix this.
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }
Lifesaver rating to anyone that can help me fix this.
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }
#include <iostream> using namespace std;
struct MovieData { char title[50]; char Director[50]; int yearReleased; int runningTime; //in minutes };
//function prototypes void ReadMovieData(MovieData&); void DisplayMovieData(MovieData);
int main() { MovieData films[2];
for(int count=0;count < 2;count++) { ReadMovieData(films[count]); DisplayMovieData(films[count]); }
return 0; }
//function definition for ReadMovieData
void ReadMovieData(MovieData &movies) { cout << "What is the title of this film: "; cin.getline(movies.title, 50);
cout << "Who is the director of this film: "; cin.getline(movies.Director, 50);
cout << "In what year was this movie released: "; cin >> movies.yearReleased;
cout << "What is the running time of this movie inminutes: "; cin >> movies.runningTime; }
//function definition for DisplayMovieData
void DisplayMovieData(MovieData display) { cout << " The title of this movie is: "; cout << display.title <<endl; cout << "The director of this movie is: "; cout << display.Director <<endl; cout << "This movie was released in the year "; cout << display.yearReleased << endl; cout << "The total running time of this movie, inminutes, is: "; cout << display.runningTime << endl; }