Xref: utzoo comp.lang.c:10513 comp.lang.c++:1205
Path: utzoo!attcan!uunet!husc6!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!uw-june!uw-entropy!dataio!pilchuck!ssc!happym!polari!rlb
From: rlb@polari.UUCP (rlb)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: I/O implementation in C and C++
Keywords: C++, I/O, buffer allocation
Message-ID: <462@polari.UUCP>
Date: 30 May 88 16:01:47 GMT
Organization: Polarserv, Seattle WA
Lines: 12



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 obvious disadvantage
to this is error detection; the programmer is surprised to discover that
although the "open" succeeded, the first I/O fails because of lack of
memory (and of course it is usually easier to isolate the open and test
its status than to do the same for the first I/O).  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?
-Ron Burk