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)
|