I can't understand why the code segment below isn't working properly. After I input a price (say 18.70), the program outputs "What is the name of this product?What is the score of this product?" as if it just ignores the getline(cin, c) command. Why does this happen? Thanks!
int a;
double b;
string c;
cout<<"What is the price of this product?";
cin>>b;
cout<<"What is the name of this product?";
getline(cin, c);
cout<<"What is the score of this product?";
cin>>a;
I'm using getline because the input might have spaces in it (I might want to enter "Buzz lightyear doll" or something), so I want to pick up the entire string.