title: C++ stringstream parsing
body: <p>I am trying to read valid a user input from command prompt:</p>
  
  <p>for example, valid user input is in following format:</p>
  
  <p>getData &lt;></p>
  
  <p>&lt;> - any string type value</p>
  
  <p>on Command Prompt:</p>
  
  <p>e.g getData name   => Correct (only one parameter entered after getData as expected)
  e.g getData name ID => InCorrect (more than one parameter entered after getData)
  e.g getData          => InCorrect  (due to no parameter entered after getData)</p>
  
  <p>How do I check for number of parameters? my code logic is as follow:</p>
  
  <pre><code>string cmd_input;
  
  getline(cin, cmd_input)
  
  stringstream ss(cmd_input);
  
  string input;
  string parameter;
  
   ss &gt;&gt; input; //getData
   ss &gt;&gt; parameter; //name
  </code></pre>
  
  <p>How do I go about valid/invalid checking? I don't want to run it through loop till EOF stream and count the number of parameter. I read up on peek() and not sure how it fits here. Also, I don't want to use vectors to store parameter.</p>
  
  <p>Thanks!</p>