小编use*_*993的帖子

getline(cin.name)被跳过

我从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)

c++ input function

4
推荐指数
1
解决办法
423
查看次数

标签 统计

c++ ×1

function ×1

input ×1