Posted by William D McQuain on November 29, 2001 at 15:33:29:
In Reply to: Stupid question, but I can't figure it out posted by Tim on November 29, 2001 at 15:02:34:
You aren't using a priming read (and you're testing for end-of-file instead of input failure). At the end of the input file, you make a pass through the loop body in which every input operation fails, then you go ahead and act as if that data was valid anyway.
: I am trying to use the following codes to read in the car data from CarCreation.txt
: while( !ins_1.eof())
: getline(ins_1, license, '\t');
: getline(ins_1, man_name, '\t');
: getline(ins_1, model, '\t');
: getline(ins_1, weight, '\t');
: ins_1 >> loc;
: "loc" is integer type and space is character type.
: It works fine except the last row of car data has initialized twice
: KVF 2794 Lincoln Mark VIII 4450 83
: Thanks for any help.
Post a Followup