title: I would like to count the numbers in a string /c++
body: <p>I have tried to count the numbers in a string but it doesnt work and I think it is logically good.   I am a beginner in programming. 
  I know it works for one-digit numbers but that's intentional. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  int main() 
  
  {
      int numbs [10] = {0,1,2,3,4,5,6,7,8,9};
      string str1;
      cin &gt;&gt; str1;
      vector &lt;unsigned int&gt; positions;
  
      for (int a = 0 ;a &lt;=10;a++) 
      {
          int f = numbs[a];
  
          string b = to_string(f);      
  
          unsigned pos = str1.find(b,0);
          while(pos !=string::npos)
          {
              positions.push_back(pos);
              pos = str1.find(b,pos+1);
              break;
          }
      }
  
      cout &lt;&lt; "The count of numbers:" &lt;&lt; positions.size() &lt;&lt;endl;
  
      return 0;
   }
  </code></pre>