title: Reading an input stream without extracting
body: <p>I'm attempting to count the number of characters in an input stream up to the first non-digit without actually extracting characters from the stream.  The input can contain any number of characters.  I need to do this to determine if I should grow a dynamic array before storing the digits in the stream in the array.</p>
  
  <p>I am limited to the following libraries: iostream, cstring, cctype</p>
  
  <p>I was thinking something like:</p>
  
  <pre><code>int counter = 0;
  const char * s = cin.getline();
  
  while( s[counter] &lt;= '0' || s[counter] &gt;= '9' )
  {
     counter++;
  }
  </code></pre>
  
  <p>But I'm having some trouble getting that to work.  Any advice would be much appreciated!</p>