[comp.lang.c++] Large stream buffers

dale@NCoast.ORG (Dale Smith) (06/18/91)

This may be a Borland specific question.  Forgive me.

How can I prevent an ofstream from flushing it's buffer until it's
full?  In Borland C++, if I allocate a larger buffer (say 32k or so),
I still seem to be doing a lot more writes to disk than necessary.

Thanks,
	dale
-- 
 Dale P. Smith
 dale@ncoast.org                         dale@harco3.uucp
 uunet!usenet.ins.cwru.edu!ncoast!dale   uunet!aablue!fmsystm!harco3!dale

steve@taumet.com (Stephen Clamage) (06/19/91)

dale@NCoast.ORG (Dale Smith) writes:

>How can I prevent an ofstream from flushing it's buffer until it's
>full?  In Borland C++, if I allocate a larger buffer (say 32k or so),
>I still seem to be doing a lot more writes to disk than necessary.

Check the buffering flags ios::stdio and ios::unitbuf for the various
output streams.

If the stdio flag for a stream S is set, cout and cerr are flushed each time
anything is written to stream S.

If the unitbuf flag for a stream S is set, S is flushed every time something
is written to it.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com

dale@NCoast.ORG (Dale Smith) (06/19/91)

In article <772@taumet.com> steve@taumet.com (Stephen Clamage) writes:
>dale@NCoast.ORG (Dale Smith) (me) writes:
>
>>How can I prevent an ofstream from flushing it's buffer until it's
>>full?  In Borland C++, if I allocate a larger buffer (say 32k or so),
>>I still seem to be doing a lot more writes to disk than necessary.
>
>Check the buffering flags ios::stdio and ios::unitbuf for the various
>output streams.

These bits are not set, at least as far as I can tell with TD.  In the
header files, they are never set, only checked.  ??????

dale
-- 
 Dale P. Smith
 dale@ncoast.org                         dale@harco3.uucp
 uunet!usenet.ins.cwru.edu!ncoast!dale   uunet!aablue!fmsystm!harco3!dale