title: Validate the length of a char * taken from std::cin
body: <p>I have a pointer called <code>char * panimal_name</code>. This pointer should only be able to take in 20 characters and if the user enters more, it must ask the user to re-enter.</p>
  
  <p>I've tried counting the characters in the stream and also using <code>strlen()</code>, however I'm still having problems.</p>
  
  <pre><code>cout &lt;&lt; "Enter Animal Name: ";
  cin.ignore();
  cin.getline(panimal_name, 20);
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>EDIT:</strong> Well I only want it to take at most 20 characters from the user.  If that 20 is exceeded it should then ask the user to re-enter valid input.  However in this setup, it now messes up the stream for my next inputs. The reason I'm using this, rather than a <code>std::string</code>, is that I'm learning pointers at the moment.</p>
  
  <p>P.S. I know a string would probably be better in this situation for ease of use.</p>