c++ - getline does not get the whole line -
here function of program. when use getline(cin,something) supposed whole line doesn't it?
void readmoviedata(moviedata *pmovie, int const size) { string title; string director; int year; int time; for(int = 0; < size; i++) { cout << "\nplease enter title of movie: "; getline(cin, title); pmovie[i].settitle(title); cin.ignore(); cout << "please enter director name of movie: "; getline(cin, director); pmovie[i].setdirector(director); cin.ignore(); cout << "please enter year released: "; cin >> year; if(year >= 1900 && year <= 2004) pmovie[i].setyear(year); else { cout << "please enter year between 1900 , 2004." << endl; year = 0; system("pause"); break; } cout << "please enter time movie last: "; cin >> time; if(time > 0 && time < 14400) pmovie[i].settime(time); else { time = 0; cout << "please enter time between 0 , 14400 in minutes." << endl; system("pause"); break; } } } when run program , enter 2 or more words, seems not work. int's takes input of words other first one. don't see problem.
this output
how many movies did watch last month? 2
please enter information of movies!
please enter title of movie: bobby lee
please enter director name of movie: scary
please enter year released: please enter year between 1900 , 2004.
press key continue . . .
here information movies!
your average time of movie is: 0
the oldest movie have watched called...
title:
director: obby lee
release year: 0
the newest movie have watched called...
title:
director: obby lee
release year: 0
process returned 0 (0x0) execution time : 11.962 s press key continue.
i want program whole name of title (1 or more words) , whole name of director(1 or more words) without error.
Comments
Post a Comment