I need to take values from a text file that looks like this:
1 2 3 4
Name Account Date Outlets Cable
John Public 01430-211230-28-9 02/02/2002 2 B
Walter Newman 29597-006105-26-2 08/16/2002 6 B
Charles Steger 18096-005492-41-6 04/14/2002 1 N
The issue is that I will not know the size of the text file, so I am currently using a while loop to stop reading the text when the EOF is reached. Here is the code I am currently using:
The output produced from this includes the last line of text twice:
John Public 01430-211230-28-9 02/02/2002
Walter Newman 29597-006105-26-2 08/16/2002
Charles Steger 18096-005492-41-6 04/14/2002
Charles Steger 18096-005492-41-6 04/14/2002
What do I need to change within the loop to allow this to work?
From ym understanding this is often the case in a while loop. Perhaps use a for and if set?
With the if statement to check the !eof() arguement and it then also writes to file. Since this will return false upon finding the eof there ought be no repeat in the outfile. Of course this requires some kind of foreknowledge of the number of lines in the data...
Perhaps have those with in the while(!eof() ) which might allow you to execute indefinitely and then only write when you have not encountered the eof.