#: 4086 S3/Languages
02-Jun-90 21:55:47
Sb: #4070-C file buffering
Fm: Mark Griffith 76070,41
To: Bob van der Poel 76510,2203
Bob,
I have heard mention of read() and write() not being kosher, mostly because
there are compilers out there that don't support them (MS-DOS types I think). I
wouldn't worry about sticking with fread() and fwrite() though. The low-level
I/O functions are much faster in my judgement.
One thing you should watch out for when using setbuf(), if you setbuf()
standard output to 0 (single character I/O), it doesn't really matter which
function (fwrite() or write()) you use...it will be slow as all get out.
Setting standard input to single character I/O makes it easier to read a single
keypress, and still allows you to read in entire lines of text without changing
anything. But, you can't use ungetc() if you need to.
For serious editing, or just about anything more involved than using the built
in line edit OS9 provides, it is usually a good practise to null out the device
descriptor for the terminal and work with each character itself without having
to worry about people having different xmode settings. It takes a bit more
work, but eliminates lots of headaches. If you also then use read() and
write() to the terminal, you'll get nice and fast screen updating.
Mark
|