title: Parse string containing numbers into integer array
body: <p>A String is given as an input which consists of numbers and I want to convert it into integer arrays in C++.</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  
  using std::string;
  using std::stringstream;
  using std::cout;
  using std::endl;
  
  int main(int argc,char** argv) {
  
      string num="-24 2 90 24 50 76";
  
      stringstream stream(num);
  
      while(stream){
          int n;
          stream&gt;&gt;n;
          cout&lt;&lt;n&lt;&lt;endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Output(GCC) :</p>
  
  <blockquote>
    <p>-24 2 90 24 50 76 76</p>
  </blockquote>
  
  <p>Why am i getting extra value and what is the efficient to convert them into integer array ? </p>
  
  <p>UPDATE:</p>
  
  <p>What if the string stream contains delimiter other than space, How to parse this?
  For eg:
   <code>string num="-24,2,90,24,50,76";</code></p>