TIP: Click on subject to list as thread! ANSI
echo: locsysop
to: Paul Edwards
from: Bob Lawrence
date: 1996-11-27 10:28:08
subject: tic

BL> Actually fgets(s, 128, *file); fputs(s, *file); is pretty good,
 BL> as long as you use it with the break to avoid adding the extra
 BL> cr/lf on the end. 

 PE> while (fgets(xxx) != NULL)
 PE> {
 PE> fputs(xxx);
 PE> }

 PE> does not cause an extra CR/LF

  I wonder what I've been doing wrong? I always end up with an extra
cr/lf on the end.

 BL> How do they do the buffer in fgets()?

 PE> Same as all the buffering, they read it into a buffer of 512,
 PE> 8192 etc bytes (or whatever you specified with setvbuf()), and
 PE> fgets just reads it out of there.

  It seems to run a bit faster than fread() with a 128-byte buffer. I
thought they might have a trick.

 PE> BTW, how did the getc() go in CRC?

  I didn't try it. Why would it be any different to fgetc()? It's much
faster to read the file into a buffer, and then do the CRC out of the
buffer.

Regards,
Bob
___ Blue Wave/QWK v2.12
@EOT:

---
* Origin: Precision Nonsense, Sydney (3:711/934.12)
SEEN-BY: 711/934 712/610
@PATH: 711/934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.