Here is a function of my program. When you use getline(cin,something) it is supposed to get the whole line doesn't it?
void readMovieData(MovieData *pMovie, int const size)
{
string title;
string director;
int year;
int time;
for(int i = 0; i < size; i++)
{
cout << "\nPlease enter the Title of the movie: ";
getline(cin, title);
pMovie[i].setTitle(title);
cin.ignore();
cout << "Please enter the Director name of the movie: ";
getline(cin, director);
pMovie[i].setDirector(director);
cin.ignore();
cout << "Please enter the year it was released: ";
cin >> year;
if(year >= 1900 && year <= 2004)
pMovie[i].setYear(year);
else
{
cout << "Please enter a year between 1900 and 2004." << endl;
year = 0;
system("PAUSE");
break;
}
cout << "Please enter the time the movie last: ";
cin >> time;
if(time > 0 && time < 14400)
pMovie[i].setTime(time);
else
{
time = 0;
cout << "Please enter a time between 0 and 14400 in minutes." << endl;
system("PAUSE");
break;
}
}
}
when I run the program and enter two or more words, it seems to not work. My int's takes the input of the words other than the first one. I don't see what is the problem.
This is my output
How many movies did you watch last month? 2
Please enter the information of your Movies!
Please enter the Title of the movie: bobby lee
Please enter the Director name of the movie: very scary
Please enter the year it was released: Please enter a year between 1900 and 2004.
Press any key to continue . . .
Here are the information with your Movies!
Your average time of all your movie is: 0
The oldest Movie you have watched is called...
Title:
Director: obby lee
Release Year: 0
The most newest Movie you have watched is called...
Title:
Director: obby lee
Release Year: 0
Process returned 0 (0x0) execution time : 11.962 s Press any key to continue.
I want the program to get the whole name of title (1 or more words) and the whole name of the director(1 or more words) without error.