Re: How to flush the ostringstream buffer?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: GuitarBill (GuitarBill_at_cox_dot_net)
Date: 07/08/04


Date: Wed, 7 Jul 2004 21:03:13 -0700

flush() doesn't clear the stream; it writes any pending [buffered] data
(useful for file streams which hold written data in memory buffer and only
actually write to file when buffer gets full or someone calls flush).
Try seekp(0) to set insert position back to start, thereby emptying string?

Bill

"Bill Sun" <sunshang@hotpop.com> wrote in message
news:uqXSKpJZEHA.3804@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I have a quetion about to refresh the ostringstream buffer: like this.
>
> ostringstream buffer;
>
> buffer << 245;
> // then the buffer.str() = "245";
>
> .....
> //next I want using this buffer again but I don't need the content of
buffer
> before, so
> buffer.flush()
> buffer << 456;
> //here I hope I can get "456" from buffer.str()
>
> but the buffer still is 245456, seem the buffer.flush not take function?
>
> why?
>
>
> who can help me?
>
> Thanks adanveced,
>
> Bill
>
>



Relevant Pages

  • Re: "secure" file flag?
    ... you really need to flush the on-device cache on each ... > pass to make sure the bit patterns get written to the platter in proper ... A simple algorithm could just mark each buffer with a special ... read all file blocks into buffers that are marked dirty and get the ...
    (freebsd-hackers)
  • Re: Response.Flush: Differences between IIS 6.0 and 5.0?
    ... since IIS 6.0 is now on top of http.sys. ... smaller buffer and so on, each flush cause the packet to send.... ... > Server: Microsoft-IIS/5.0 ...
    (microsoft.public.inetserver.iis)
  • Re: Can anyone explain why this is happening?
    ... Is it possible that your writes do not include a local buffer flush ... written file (to guarantee that newly written data have been flushed to ... before it reads from a new file (which also flushes all buffered written ...
    (comp.parallel.mpi)
  • Re: Problems with sys.stout.flush()
    ... Carl Banks wrote: ... console until it sees a newline unless you flush the buffer. ... option for python and a few examples from this sitehttp://stackoverflow.com/questions/107705/python-output-buffering ...
    (comp.lang.python)
  • Re: File output buffer overrun?
    ... > old IBM mainframe Fortran 77 compiler to a modern Linux system. ... a 4K buffer, so it sounds like you're getting far enough into the code ... to flush the buffer ONCE but then the code crashes before the next ... more calcs ... ...
    (comp.lang.fortran)