-2

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.

I thought to use something like this: (which similar questions would suggest)

    do
    {

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

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

    cout << charCount;

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:

Error C2065 'fin': undeclared identifier

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

Elliander
  • 503
  • 1
  • 9
  • 19
  • OK, could you guys STOP down voting this? I'd rather not get banned for life because you don't like the question. So I overlooked something. It's still a well written question that is simple and to the point. – Elliander Feb 20 '16 at 19:29

1 Answers1

2

file is the name of your ifstream, right? If so, line

fin >> temp;

should be

file >> temp;
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
NickLamp
  • 862
  • 5
  • 10