Hello,
I am coding a program that inputs data from a file. I have a loop that will input each line and then output each line. I have the while loop set as:
while (! file.EOF())
{
...
)
For some reason, the loop will process and output the last record in the file twice. For example, if my file was like the following:
John_Doe 1234
Jane_Doe 4567
Fred_Flintstone 8901
The while loop will output it as this:
John_Doe 1234
Jane_Doe 4567
Fred_Flintstone 8901
Fred_Flintstone 8901
It seems that the program knows that it's the EOF, but for some reason it processes the last record twice. And since it processes it twice, of course it messes up the rest of my calculations in the program. What am I doing wrong here? Thanks.
I am coding a program that inputs data from a file. I have a loop that will input each line and then output each line. I have the while loop set as:
while (! file.EOF())
{
...
)
For some reason, the loop will process and output the last record in the file twice. For example, if my file was like the following:
John_Doe 1234
Jane_Doe 4567
Fred_Flintstone 8901
The while loop will output it as this:
John_Doe 1234
Jane_Doe 4567
Fred_Flintstone 8901
Fred_Flintstone 8901
It seems that the program knows that it's the EOF, but for some reason it processes the last record twice. And since it processes it twice, of course it messes up the rest of my calculations in the program. What am I doing wrong here? Thanks.