> My C program prints the last line of text file twice. below is the part of
> my code

>     while (!feof(infile)) {

feof only returns true after an attempt has been made to read from the
file and EOF was encountered. So, the loop will iterate one more time
than specified i.e. at end.

Since this input request failed, the last successfully read line is
used. The result is that the last line of the file is processed twice.

-- 
Mohit Singh

GNU/Linux User Group - Meerut

-- 
l...@iitd - http://tinyurl.com/ycueutm

To unsubscribe, reply using "remove me" as the subject.

Reply via email to