title: How to convert numbers into vector of integers?
body: <p>I want my program to ask the user to input any number and then store it into a <code>std::vector</code> where every single digit is allocated to a separate vector index:</p>
  
  <pre><code>input: 142
  
  output vector: [1, 4, 2]
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>int main()
  {
       std::vector&lt;int&gt; v;
       int number;
       cin &gt;&gt; number;
       for(unsigned int i = 100; i &gt; 0; i/=10)
       {
           v.push_back(number/i);
           number -= (number/i)*i;
       }
  
       for(size_t i = 0; i &lt; v.size(); ++i)
       {
           std::cout&lt;&lt;v[i]&lt;&lt;std::endl;
       }
  }
  </code></pre>
  
  <p>It works. But what should I do when the input-length is unknown?</p>