Counting number of integers in text file (undeclared identifier using fin>>x) : <p>I have a text file with an unknown number of integers. I created a dynamic array without trouble, but the numbers have varied spacing and digits. I would normally go through each position to count the number of spaces used, subtracting space from it, but that won't work in this case.</p>

<p>I thought to use something like this: (which similar questions would suggest)</p>

<pre><code>    do
    {

        if (!file.is_open())
        {
            file.open(donation);
        }

        fin &gt;&gt; temp;
        charCount++;
    } 
    while (file.peek() != EOF);

    cout &lt;&lt; charCount;
</code></pre>

<p>Now, I have fstream included, and I am using namespace std, and I have no problem opening and reading the text file, but visual studio 2015 tells me:</p>

<p>Error   C2065   'fin': undeclared identifier</p>

<p>I don't understand what I am doing that is triggering that type of response from the IDE.</p>
