Hi guys I'm trying to write a program for class and I'm having trouble getting it to read all the values in the input file and outputting them. Sorry about asking this, but the teacher I have is no good and the book only does so much. Also i was wondering if i could use eof too see when it reaches the end of file, but my program says: std::string' has no member named 'eof' when i try it.
Here's my code so far. Tried using the eof in line 27:
First, on line 25, on your while loop, you have no closing bracket, unless you copy pasted wrong.
Second, instead of a while loop (a pretest loop) you could change to a posttest loop in do/while, and use while(fin.good()).
But to answer your question, the fin.eof() should return false until eof is reached, at which time it will return true.
Why you are getting that error, I think it is because you are trying to use it on a file instead of a stream, I believe it is intended to be used on the stream. Try changing it from fileName.eof to fin.eof()
Strings don't have and eof. Files do. You probably wanted to do some_fstream.eof() instead. In any case, that if statement is useless as it does nothing.
EDIT: Beaten by there. Soko is right, there are several other errors besides that you ought to fix.
I have been working with c++ for half a year now (still pretty new myself) and with some projects I still do that. I throw it together, and once I have the raw raw draft of it, I fix all my errors then go from there. :)