title: Function that counts the number of integers in a text file?
body: <p>I need to write just a function that counts the number of integers in an already opened and good text file.</p>
  
  <p>a. Assume there is a text file with a large number of integers divided by spaces</p>
  
  <p>b. Write a function called analyzeFile that accepts a previously opened ifstream
  file object as a parameter, and counts the number of integers in the file.</p>
  
  <p>c. It does not need to do anything with the integers, but it must count exactly the
  correct number of integers in the file and return that number to the calling
  function.</p>
  
  <p>d. It also does not need to manipulate the file operations themselves, so it does not
  need to close the file or conduct any other actions other than counting the integers
  and returning the number of them.</p>
  
  <p>Thank you for any help on my problem!</p>
  
  <p><strong>Edit:</strong>
  Here is what I have as a function do far, is it right, I don't know: </p>
  
  <pre><code>int analizeFile (ifstream &amp;inf, const string &amp;fileName) { 
     int count = 1; 
     int num; 
     fin.open(fileName.c_str() ); 
     fin &gt;&gt; num; 
     while (fin.good() ) { 
        fin&gt;&gt; num; 
        count ++; 
     } 
     return count;
  } 
  </code></pre>