I have this function:
void read(){
int id;
string desc;
string title, type;
cout<<"Movie's id: ";
cin>>id;
cout<<"Movie's title: ";
cin>>title;
cout<<"Movie's description: ";
getline(cin, desc, '\n');
cout<<"Movie's type: ";
cin>>type;
cout<<"You have typed in: "
<<id
<<" "
<<title
<<" "
<<desc
<<" "
<<type
<<".\n";
}
and my problem is that in the desc field, when I must insert something, it skips over, passing to the type field, not letting me insert anything. I've tried in another project only with the getline(cin, desc, '\n')
and it worked, it took all the line, but here it just skips the field. My question is this: why does this thing happens? and did I do something wrong?
10x.