Re: How to flush the ostringstream buffer?
From: GuitarBill (GuitarBill_at_cox_dot_net)
Date: 07/08/04
- Previous message: Bill Sun: "How to flush the ostringstream buffer?"
- In reply to: Bill Sun: "How to flush the ostringstream buffer?"
- Next in thread: Jonathan Turkanis: "Re: How to flush the ostringstream buffer?"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Previous message: Bill Sun: "How to flush the ostringstream buffer?"
- In reply to: Bill Sun: "How to flush the ostringstream buffer?"
- Next in thread: Jonathan Turkanis: "Re: How to flush the ostringstream buffer?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|