- Sep 3, 2001
- 61
- 0
- 0
ran into a little problem with a program I'm doing...
say I have:
string userdate, bookisbn, booktitle;
int bookquantity;
float bookprice, total, tax, final;
cout << "Date: ";
cin >> userdate;
cout << "Quantity of Book: ";
cin >> bookquantity;
cout << "ISBN: ";
cin >> bookisbn;
cout << "Title: ";
cin >> booktitle;
cout << "Price: ";
cin >> bookprice;
It'll work fine if the user inputs a title with no spaces, but if there are spaces, then cin >>bookprice is skipped. I've tried using getline(cin, booktitle) and cin.ignore(), but nothing works completely. Any help I would apreciate.
say I have:
string userdate, bookisbn, booktitle;
int bookquantity;
float bookprice, total, tax, final;
cout << "Date: ";
cin >> userdate;
cout << "Quantity of Book: ";
cin >> bookquantity;
cout << "ISBN: ";
cin >> bookisbn;
cout << "Title: ";
cin >> booktitle;
cout << "Price: ";
cin >> bookprice;
It'll work fine if the user inputs a title with no spaces, but if there are spaces, then cin >>bookprice is skipped. I've tried using getline(cin, booktitle) and cin.ignore(), but nothing works completely. Any help I would apreciate.
