FidoNet Echomail Archive

<<< Previous Index Next >>>

From: Frank Adam
To: Peter Haywood
Date: 1997-05-01 08:20:36
Subject: Re: Borland C bug ?!?

On Mar 25 02:07, 1997, Peter Haywood of 3:633/159 wrote:
G'day Peter ,

PH> {at}MSGID: 3:633/159.0 333779c8
PH> {at}PID: BWRA 3.02 [Reg]
PH> {at}TID: FastEcho 1.45 10109
PH> Groovy hepcat Frank Adam jived with Paul Edwards on 27 Feb 97  
PH> 19:31:00!
PH> Re: Borland C bug ?!?'s a cool scene. Dig it!

FA>> while(NULL != fgets(buf,80,in))
FA>> ((p = strrchr(buf,'\n')) != NULL) ? *p = '\0' : panic();

PH>   No, you don't need to do that. If fgets() reaches EOF while reading
PH> bytes, it still returns a valid string. You don't need to check for a
PH> '\n' character or append a a '\0' to the string. (Of course, if some
PH> error is encountered the returned value may not be valid).
True, i was in the belief that fprintf appends a '\n' to the end of every 
line. Unfortunately this means that reading in an unknown text file there 
is no way of determining whether the file is corrupt or not. With a data file
one can always be sure that it'll have a multiple of datasize bytes, with
the text file only the user can notice the garbage, we can't.

 Regards, Frank

--- Msged 4.00
 * Origin: The ticking point, Melbourne, Australia. (3:635/728.21)
SEEN-BY: 633/267 270
@PATH: 635/728 633/267

<<< Previous Index Next >>>