reading a text file word by word until eof

Please help me understand the theory of this. I need to read each word in a text file (StudentFile is the ofstream object) and assign it to a structure array. I can not use a vector

while (StudentFile >> FirstName >> LastName >> StudentId >> NumberOfGrades)
{ assign }

would this while statement keep looping until the eof or would it stop after "NumberOfGrades" regardless of the number of lines in the file?

or would I need to use a test like:

while (!StudentFile.eof){ while (StudentFile >> FirstName >> ...etc...)
{assign}
}

or am I completely off my rocker?
> while (StudentFile >> FirstName >> LastName >> StudentId >> NumberOfGrades)
> would this while statement keep looping until the eof

It will keep looping until the attempted input fails, which may be caused by:
a. badly formed input - for instance, non-numeric characters where a number is expected
b. end of file - there is nothing more to read
c. any other kind of input failure - for instance, the file is on removable media which was forcibly unmounted.
Thank you!!
Topic archived. No new replies allowed.