title: How do I get my checkLength function to loop until the user enters in a password of more than 5 characters?
body: <p>Okay so i am working a project where we are storing user input to create a username and password and storing it within a vector. My main issue is that everytime i use the checkLength function it still takes the user's password even though its less than 5 characters for example here's the output i am getting '</p>
  
  <pre><code>Enter your first name.
  John
  Enter your last name.
  Stewart
  Enter a password.
  abc
  Password is not 5 characters.  please try again...
  
  /**it displays the message but still 
     continues instead of making the user input a 5 character password**/
  
  Enter your first name.
  Example
  Enter your last name.
  exmaple
  Enter a password.
  prob
  Password is not 5 characters.  please try again...
  Enter your first name.
  0
    Login data entered
  
    JStewa, abc
    Eexmap, prob
  Press any key to continue . . .
  </code></pre>
  
  <p>How do I fix this or why is it looping even though the user only entered a three character password!</p>
  
  <p>here is my code</p>
  
  <pre><code>//DISPLAY 8.9 Using a Vector
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  using namespace std;
  #include "c:\Users\barta\OneDrive\Documents\Visual Studio 2015\Projects\Project 7\Project 7\Validate.h"
  
  int main( )
  {
  
      vector&lt;string&gt; data;
      string firstName, lastName, login, userName, password;
      Validate c;
  
      firstName = "1";
  
      cout &lt;&lt; "Enter your first name.\n";
      getline(cin, firstName);
      while (firstName != "0")
      {
  
          cout &lt;&lt; "Enter your last name.\n";
          getline(cin, lastName);
          do
          {
              cout &lt;&lt; "Enter a password.\n";
              getline(cin, password);
  
              c.checkLength(password);
  
              lastName = lastName.substr(0, 5);
  
              userName = firstName.at(0) + lastName;
              login = userName + ", " + password;
              data.push_back(login);
          } while (false);
  
          cout &lt;&lt; "Enter your first name.\n";
          getline(cin, firstName);
      }
  
      cout &lt;&lt; "  Login data entered \n" &lt;&lt; endl;
  
          for (unsigned int i = 0; i &lt; data.size(); i++)
          {
              cout &lt;&lt; "  " &lt;&lt; data.at(i) &lt;&lt; endl;
          }
  
  
  
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>Validate header file:</p>
  
  <pre><code>class Validate
  {
  public: 
      Validate(string);
      Validate();
      bool checkLength(string);
      bool checkSpaces();
      bool checkUpper();
  private:
      string password;
      static const int LEN = 5;
  
  };
  Validate::Validate()
  {
  
  }
  Validate::Validate(string pass)
  {
      pass = password;
  }
  bool Validate:: checkLength(string password)
  {
  
          if (password.length() &lt; LEN)
          {
              cout &lt;&lt; "Password is not 5 characters." &lt;&lt; "  please try again..." &lt;&lt; endl;
              return true;
          }
          else
          {
              return false;
          }
  
  }
  </code></pre>