Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

maatlof

macrumors newbie
Original poster
Dec 15, 2010
1
0
Hi!

I've done this structure:

struct info {
string singer;
string title;
int stock;
float price;
};

and this function:

void lectura (info &cd){
cout << endl << "Introduce the CD's information: " << endl;
cout << "Singer: ";
getline(cin, cd.singer);
cout << "Title: ";
getline(cin, cd.titulo);
cout << "Products in stock: ";
cin >> cd.stock;
cout << "Price: ";
cin >> cd.price;
}


It does run in the main function, where there is a loop that make it repeats. The first time it works ok, but the next times when it is supposed to get the singer's name "getline (cin, cd.singer)" it doesn't let me write it, because it appears the new "cout" "Title: " and it gets no string in it. The executable shows like this:

Introduce the CD's information:
Singer: Title: Hello
Products in stock: 3
Price: 2

Why does it happen?

Thank you very much!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.