where is EOF?

I have this app that loads data into Oracle that runs like so . . .

getlist.pl | merge -lscott/tiger

getlist.pl gives data in the following format:

NAME1 TABLE1 LOCATION1
NAME2 TABLE2 LOCATION2
NAME3 TABLE3 LOCATION3
. . .

for some reason merge processes the last record of the perl script output twice.

. . .
NAME2 TABLE2 289 0
NAME3 TABLE3 276 0
NAME3 TABLE3 276 0

So it's loading the last file twice.

my code it like so . . .

while(!cin.eof()) {
cin >> name;
cin >> table;
cin >> location;

//do some stuff . . .

}

For some reason it doesn't appear to recognize the EOF from a std input stream until it processes the last record twice in the std input stream.

I didn't write this code, only maintaining it. Author has left the company.

Any help is much appreciated.

Thanks.
verWire3619




The eof flag will be set when you attempt to read but you reached the end of file. (too late)
1
2
//while( not cin.eof() )
while( cin>>name>>table>>location )
Thank you. This resolved the issue.
Topic archived. No new replies allowed.