I'm back again with another question -_-
sorry for asking too much in this single project but i ask these questions because for me, these are "no way out" questions
this is the original code fragment in my program
1 2 3
|
cout << "Enter the name of the movie you want to enter: "; cin >> Mname;
cout << "Enter the year when the movie was shown: "; cin >> Myear;
insert2(Mname, Myear);
|
and the output was
Enter the name of the movie you want to enter: taken
Enter the year when the movie was shown: 2008
|
but since not all movies has only one word... i knew
cin
won't work. so i changed the code to this
1 2 3
|
cout << "Enter the name of the movie you want to enter: "; getline(cin, Mname);
cout << "Enter the year when the movie was shown: "; cin >> Myear;
insert2(Mname, Myear);
|
notice in line 1 that i changed
cin
to
getline(cin, Mname)
in order to store movies that has a title of more than one word
but things become worse because the output of the changed code was this
Enter the name of the movie you want to enter: Enter the year of the movie was shown: 2008
|
the program doesn't ask for the movie title anymore and it skips the
getline(cin, Mname)
part. i was very sure that i typed
#include<string>
at the very beginning of the program and
cin >> Mname
was the only code i changed
I wonder where i went wrong? :(
Note: this is only a tiny fragment of my program. if you need to see the rest pls feel free to ask