Is there any good reason why:
std::string input;
std::getline(std::cin, input);
the getline call won’t wait for user input? Is the state of cin messed up somehow?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most likely you are trying to read a string after reading some other data, say an
int.consider the input:
if you use the following code:
the
getlinewill only read the newline after 11 and hence you will get the impression that it’s not waiting for user input.The way to resolve this is to use a dummy
getlineto consume the new line after the number.