title: How To Read Multiple Integers from a String C++
body: <p>I'm trying to understand how can I convert multiple integers from a string. I have tried to use <code>atoi()</code>, <code>stoi()</code> and <code>istringstream()</code> and they all do the same thing. I can't get more than one integer.</p>
  
  <p>For example, if the string is <code>"Chocolate and Milk 250 pounds and 2 oz or 1.5 coins."</code>
  All of the above functions will not work. It won't take the whole string. If I leave only a single number then it will work. I want to be able to read the whole string and get all of the <em>integers only</em> (not <em>float</em>).</p>
  
  <p>I am using a <code>while(getline())</code> for the string. Then try to get it into string.</p>
  
  <p>Although, if I could only return the total amount of integers in the string that would be better. Either way, I'm trying to learn both ways. In this case, the output would be <code>"2"</code>, since there are only two int.</p>