Hi! I'm writing a program to manipulate data from a text file. The text file includes names followed by the data (ints) associated with that name (e.g., "Name1 1 1 2 3 4 Name2 3 2 1 1"). I'm expecting the code below to read in the name and then read all the data until it gets to the next name, and then start over with the next person's name and results. I want it to do this until every participants data has been read. I'm expecting the code below to cout: "Name1 1 1 2 3 4 Name2 3 2 1 1". Instead it couts this: "Name1 1 3 4" and then the window scrolls down infinitely.
After it has failed to read a number the failbit will be set. No read operations will succeed as long as the failbit is set. To unset the failbit you have to call the clear function. ourfile.clear();
And you should probably not be using eof in the loop condition because the eofbit might be set too late. Instead I would use line 12 as a loop condition. That also handles other kinds of errors better.