title: C++ eof() problem - never returns true?
body: <p>So I'm trying to read this file. Everything looks like it should work, but during runtime the program times out and stops working, and I have to close it. What is going on? I suspect that the oef() test is never returning true and it keeps looking for more in the file. I have no dragging empty lines in the text file. I've tried debugging this like crazy. I can't find anything wrong but it still refuses to work.</p>
  
  <pre><code>Pet** petArray;
  
  ifstream textFile2;
  textFile2.open("pets.txt");
  
  int i = 0;
  string temp;
  int tmpNum = 0;
  
  if (textFile2.is_open())
  {
      while (!textFile2.eof())
      {
  
          getline(textFile2, temp);
  
          petArray = new Pet*[arraySize];
  
          if (temp == "Dogs" || temp == "Cats" || temp == "Iguanas" || temp == "Pigs")
          {
              if (temp == "Dogs") tmpNum = 0;
              if (temp == "Cats") tmpNum = 1;
              if (temp == "Iguanas") tmpNum = 2;
              if (temp == "Pigs") tmpNum = 3;
              temp == "";
          }
          else
          {
              if (tmpNum == 0)
              {
                  petArray[i] = new Dog(temp);
                  cout &lt;&lt; "Dog " &lt;&lt; temp &lt;&lt; " added" &lt;&lt; endl;
              }
              if (tmpNum == 1)
              {
                  petArray[i] = new Cat(temp);
                  cout &lt;&lt; "Cat " &lt;&lt; temp &lt;&lt; " added" &lt;&lt; endl;
              }
              if (tmpNum == 2)
              {
                  petArray[i] = new Iguana(temp);
                  cout &lt;&lt; "Iguana " &lt;&lt; temp &lt;&lt; " added" &lt;&lt; endl;
              }
              if (tmpNum == 3)
              {
                  petArray[i] = new Pig(temp);
                  cout &lt;&lt; "Pig " &lt;&lt; temp &lt;&lt; " added" &lt;&lt; endl;
              }
              arraySize++;
          }
  
          i++;
      }
  }
  </code></pre>
  
  <p>Here is the format of the text file:</p>
  
  <pre><code>Dogs
  d1
  d2
  Cats
  c1
  c2
  Iguanas
  i1
  i2
  Pigs
  p1
  p2
  </code></pre>
  
  <p>Any suggestions?</p>