0

I've been looking for a concise answer to my question. It seems to be a very common issue but I haven't seen anyone that has asked the question in a tightly focused way nor have I found an appropriate answer.

I'm just trying to find out how many lines are in a particular file using the filename.eof() command. Like so:

ifstream InFile;
InFile.open("Input.txt")    
int counter=0;
while(!InFile.eof())
  counter++;

I've been finding that sometimes the condition works when using it for other things but not always. I don't understand what the difference is and I don't know why. Can anyone explain? Help would be greatly appreciated.

ClimbingTheCurve
  • 323
  • 2
  • 14

0 Answers0