Cin不等待输入

时间:2016-12-04 01:26:18

标签: c++ iostream cin

以下代码会跳过第一个getline提示,但会等待第二个提示。

cout << "Enter a new animal in the form of a question," << endl << "e.g., 'Is it a whale?': " << endl;
getline(cin, first_question);
cout << "\nNow enter a question for which the answer is 'yes' for your new" << endl << "animal, and which does not contradict your previous answers: " << endl;
getline(cin, second_question);

0 个答案:

没有答案