这是我的主要程序,如何阻止程序跳过getline?
int main() {
string command;
cin>>command;
if(command == "keyword")
{
string str, str2, str3, str4;
cout << "Enter first name: ";
getline (cin,str);
cout << "Enter last name: ";
getline (cin,str2);
cout << "Enter age: ";
getline (cin,str3);
cout<<"Enter country: ";
getline (cin,str4);
cout << "Thank you, " << str <<" "<<str2 <<" "<<str3<<" "<<str4<< ".\n";
}
}
当输入关键字时,该程序立即输出:
输入名字:输入名字:
完全绕过输入名字的能力。
特别[ignoreline和“blankline提取器“函数](http://bitbucket.org/kniht/scraps/src/fdf116645350/cpp/kniht/clinput.hpp#cl-28)可以使这更容易。 – 2010-11-01 08:06:16
namespace'kniht'? – 2010-11-01 08:09:46