questions about a backup program for the MS-DOS environment

Walter Bright bright at Data-IO.COM
Sat May 5 05:18:30 AEST 1990


In article <CLINE.90May3130316 at cheetah.ece.clarkson.edu> cline at sun.soe.clarkson.edu (Marshall Cline) writes:
<Note that Walter used read()/write() as opposed to fread()/fwrite().
<In Turbo-C, it's even faster (probably 2 to 3 times faster!) to use
<_read() and _write(), since read()/write() can end up
<deleting/inserting ^J if the files are in text mode.
<I found fread()/fwrite() in Turbo-C to be embarassingly & surprisingly
<slow.  After tracing them, I found they resolved to loops of
<fgetc()/fputc() rather than the seemingly more obvious read()/write(),
<apparently since fgetc()/fputc() know about buffering.  However it
<wouldn't be hard to fix fread()/fwrite() to do it `right'!

But I wasn't using Turbo C, I was using Zortech C! In Zortech C, read()/
write() resolve directly to calls to MSDOS. read()/write() do not do
CR-LF translation. I always felt it was silly to have them do such
translation, thus creating 3 levels of I/O instead of 2. If you want
CR-LF translation, use fgetc/fputc.

BTW, fread/fwrite directly memcpy the bytes from/to the I/O buffer, they
are not loops around fgetc/fputc for the Zortech libraries.



More information about the Comp.lang.c mailing list