title: How to obtain the whole integers from file has strings and integers and store them into array in C++?
body: <p>I want to obtain integers from file that has strings too, and store them into array to do some operation on them. the integers can be 1 or 12 or 234, so 3 digits. I am trying to do that but the output stops when I run the code</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void GetNumFromFile (ifstream &amp;file1, char &amp; contents)
  {
      int digits[20];
      file1.get(contents);
      while(!file1.eof())
      {
          for (int n = 0; n &lt; 10; n++)
          {
              if(('0' &lt;= contents &amp;&amp; contents &lt;= '9') &amp;&amp; ('0' &gt;= contents+1 &amp;&amp; contents+1 &gt; '9'));
              digits[n]=contents;
              if(('0' &lt;= contents &amp;&amp; contents &lt;= '9') &amp;&amp; ('0' &lt;= contents+1 &amp;&amp; contents+1 &lt; '9'));
              digits[n]=contents;
              if(('0' &lt;= contents &amp;&amp; contents &lt;= '9') &amp;&amp; ('0' &lt;= contents+1 &amp;&amp; contents+1 &lt;= '9') &amp;&amp; ('0' &lt;= contents+2 &amp;&amp; contents+2 &lt; '9'));
              digits[n]=contents;
          }
          continue;
      }
      for (int i = 0; i &lt;= 20; i++)
      {
          cout &lt;&lt; *(digits + i) &lt;&lt; endl;
      }
  }
  </code></pre>