I/O implementation in C and C++

Mike Coffin mike at arizona.edu
Thu Jun 2 00:27:41 AEST 1988


>From article <462 at polari.UUCP>, by rlb at polari.UUCP (rlb):
> 
> 
> I find it interesting that both K&R (C) and Stroustrup (C++) give
> I/O package implementation examples in which buffer allocation takes
> place at the first I/O, rather than in the "open".
> ... The only advantage I
> can think of is that if an "open" is performed but no I/O is requested,
> you've saved a bit of memory.  Are there other advantages?
For one thing, it makes setbuf(3s) possible.  You could instead
add an optional argument to "open" to specify a buffer, but this mucks
up the interface for lots of users who never use setbuf.
-- 

Mike Coffin				mike at arizona.edu
Univ. of Ariz. Dept. of Comp. Sci.	{allegra,cmcl2,ihnp4}!arizona!mike
Tucson, AZ  85721			(602)621-4252



More information about the Comp.lang.c mailing list