我从C++中的一个函数调用一个函数,该函数的getline(cin,name)名称是一个字符串.第一次循环,程序不等待输入.它将在所有其他通过循环.有什么想法吗?
void getName (string& name)
{
int nameLen;
do{
cout << "Enter the last Name of the resident." << endl << endl
<< "There should not be any spaces and no more than 15"
<< " characters in the name." << endl;
getline(cin,name);
cout << endl;
nameLen = name.length();// set len to number of characters input
cout << "last" << name << endl;
}
while (nameLen < LastNameLength);
return;
}
Run Code Online (Sandbox Code Playgroud)