FidoNet Echomail Archive
aust_c_here

<<< Previous Index Next >>>

From: Peter Haywood
To: Frank Adam
Date: 1997-03-25 02:07:34
Subject: Re: Borland C bug ?!?

Groovy hepcat Frank Adam jived with Peter Haywood on 02 Mar 97  13:53:04!
Re: Borland C bug ?!?'s a cool scene. Dig it!

 PH> Try this instead; it may not work, but it might:
 FA> It needs a little correction..

  Yes, I realise that now. I should've used NULL instead of EOF.
 
 PH> while (fgets(s,500,fp) != EOF)
 FA> {
 FA> printf("\nI will not let him compare negative ints to char*.");
 FA> }

 FA> That'll teach that naughty compiler of yours.;-)      
 
  My compiler's a good compiler, a goood compiler. (I have to keep
telling myself that to justify paying a fortune for it.) I'm just not
very experienced yet, I'm afraid. But I'm learning more all the time,
thanks to people like you you who correct me when I make a boo boo and
get me thinking.

 FA> But here is the ultimate test.. 

 FA> fseek(fp,0L,SEEK_END);
 FA> size = ftell(file); 
 
  Huh, file? fp you mean?

 FA> rewind(fp);
 FA> 
 FA> while(fgets(s,500,fp) != NULL)

     {

 FA> if(!ferror(fp) && !errno && !feof(fp) &&
ftell(fp) < size) 
 
  The check for EOF via feof() is not necissary, I think. If EOF has
been reached, s will still contain the last piece of the file. The
comparison of fgets(s,500,fp) to NULL stops the loop attempting to
read any more bytes from the file.

 FA> process(s);
 FA> else break;
 FA> } 

 FA> Did i forget anything (apart form my medication) ? ;-)

  Maybe reset errno before entering the while loop, as a precaution.
Other than that, I can't think of anithing else. But lacking
experience, I may have missed something.


                                                  Wolvaen


... It shoulda been a show about someone copping a feel. - Butt Head
--- Blue Wave/RA v2.20
 * Origin: The Gate, Melbourne Australia, +61-3-9809-5097 28.8k  (3:633/159)
SEEN-BY: 633/267 270
@PATH: 633/159 154 374 632/360 50/99 635/728 633/267



<<< Previous Index Next >>>