title: Need user to input string /check string length (C++)
body: <p>I'll need to accept a string of 5 numbers from the user (only 5).
  Should I use </p>
  
  <pre><code>istringstream 
  </code></pre>
  
  <p>for the same ?</p>
  
  <p>Can't I get away with something like this ?</p>
  
  <pre><code>int main()
  {
      char *InputMain;
      InputMain=(char *)malloc(5+1);
      cout &lt;&lt; "Enter the number : " &lt;&lt;endl;
      cin.getline ( InputMain, 5, '\n' );              // Input goes into InputMain
      cout &lt;&lt; "The number entered is : " &lt;&lt; InputMain &lt;&lt;endl;
      cin.get();
  }
  </code></pre>
  
  <p>Then comes the next part..</p>
  
  <p>How'd I make sure the user inputs only 5 chars? And maybe if the user enters more than 5 chars, I should display a warning saying only 5 chars allowed..</p>
  
  <p>One more question, since this essentially is a string, I'll need to validate the input to be only numbers by parsing through each char in the string and checking against respective ASCII values (for numerals).. Is that approach the right thing?</p>