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

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

PE> does not cause an extra CR/LF

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

Do a hexdump of the file.

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.

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

They do - they don't need to look for the CRLF at the end of the line for
when you do fgets().

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

BL> I didn't try it. Why would it be any different to fgetc()? It's much

It's a macro instead of a function call.

BL> faster to read the file into a buffer, and then do the CRC out of the
BL> buffer.

Which is actually what both fgetc() and getc() do, sort of.  BFN.  Paul. 
@EOT:

---
* Origin: X (3:711/934.9)

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™.