0
void NewCustInfo(CustData &cust)
{
	cout << "Customer Name: ";
	getline(cin, cust.name);

}

CustData is a structure that is declared, and the name data member of that struct is of type string. For some reason when I call this function(there are no compile errors), it displays the cout statement, but then completely skips over the getline function. Any ideas?

Thanks

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by clutchkiller
0

Does it occur after some other input? If so, there may be still be some lagging information in the input stream that it's grabbing.

Try placing cin.ignore(); directly before it.

Edited by Fbody: n/a

0
void NewCustInfo(CustData &cust)
{
	cout << "Customer Name: ";
	getline(cin, cust.name);

}

CustData is a structure that is declared, and the name data member of that struct is of type string. For some reason when I call this function(there are no compile errors), it displays the cout statement, but then completely skips over the getline function. Any ideas?

Thanks

Its probably most likely that there is a new line character in the stream. This happens when you read in a number. As suggested,
place cin.ignore() as the first statement in the function. Then go
on normally.

0

Thanks guys, that fixed my problem. I shoulda been able to figure that out on my own =(

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.