This is my code I don't really see the problem here I'm sure its something simple that I just need another fresh pair of eyes to find.
#include <iostream>
#include <string>
using namespace std;
//Struct
struct MovieData
{
string title;
string director;
int year;
int runTime;
double productionCost;
double fYRevenue;
};
//Prototypes
MovieData getMovieData();
void printMovieData(MovieData );
int main()
{
//Variables
MovieData m1, m2;
cout << "Enter data for movie 1:";
m1 = getMovieData(); //call get data
cout << "Enter data for movie 2:";
m2 = getMovieData(); // Call get data
printMovieData(m1); //Call print
printMovieData(m2); //Call print
return 0;
}
/*
Passes a struct of type movie data and
collects data needed to print out
later on
*/
MovieData getMovieData()
{
MovieData m;
char line;
cout << "\n\nWhat is the title of the movie?: ";
getline(cin, m.title);
cout << "\nWho was the director of the movie?: ";
getline(cin, m.director);
cout << "\nWhat year was the movie made?: ";
cin >> m.year;
cout << "\nHow long is the movie in minutes?: ";
cin >> m.runTime;
cout << "\nHow much did it cost to produce this movie?: ";
cin >> m.productionCost;
cout << "\nHow much did the movie make in its first year?: ";
cin >> m.fYRevenue;
cout << "\n";
return m;
}
/*
Passes a variable of type movie data
then prints out the information inside
*/
void printMovieData(MovieData m)
{
cout << "\n\nThe movie data for " << m.title << " is as follows.\n";
cout << "Title: " << m.title;
cout << "\nDirector: " << m.director;
cout << "\nYear Made: " << m.year;
cout << "\nRunning Time: " << m.runTime;
cout << "\nProduction cost: " << m.productionCost;
cout << "\nRevenue: " << m.fYRevenue ;
}
If you guys can find the problem I'd greatly appreciate it I've been messing with it for a bit and I just cannot understand the issue here. The second time getMovieData is called the first title is a blank line. However when I had them as cin << m.title; etc it was skipping the entire function to the end when I entered input with two parts such a The Flood same with the Directors name Carl Simons would skip the entire thing as well.