FidoNet Echomail Archive
aust_c_here

<<< Previous Index Next >>>

From: David Nugent
To: Joshua Marshall
Date: 1997-02-19 14:46:36
Subject: Borland C bug ?!?

 > JM>>>> while (!feof(fp))
 > JM>>>> {
 > JM>>>> fgets(s,500,fp);
 > PE>>>    ^^^^^^^^^^^^^^^^
 > JM>>>> blah blah
 > JM>>>> }
~
 > PE> Like I say, you have a bug.  !feof(fp) will be true,
 > because you haven't
 > PE> hit EOF, fgets() will return NULL, because it reaches EOF when reading
 > PE> the line, and you ignore that return code, and use s regardless.  s
 > PE> will have junk in it.

 > Step 1: Check for EOF
 > Step 2: If not at EOF, read data.
 > Step 3: process data
 > Step 4: go to Step 1.

 > This is what I am doing.

Yes, but when you "read data" in step two, you may well detect
eof. The end of file is not detected until reading data beyond it is
actually attempted, not before.

--- MaltEd/2 1.0.b6
 * Origin: Unique Computing Pty Limited (3:632/348)
SEEN-BY: 50/99 54/99 620/243 623/630 632/103 107 348 360 601 633/374 635/544
SEEN-BY: 635/728 639/252 640/820 711/413 430 934 712/311 407 505 506 517 623
SEEN-BY: 712/624 704 841 713/317 714/906 800/1
@PATH: 632/348 360 50/99 712/624 711/934


<<< Previous Index Next >>>