Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2004

Tip: Looking for answers? Try searching our database.

How to flush the ostringstream buffer?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Sun - 08 Jul 2004 04:22 GMT
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
GuitarBill - 08 Jul 2004 05:03 GMT
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

> Hi,
>
[quoted text clipped - 21 lines]
>
> Bill
Jonathan Turkanis - 08 Jul 2004 05:33 GMT
> Hi,

> I have a quetion about to refresh the ostringstream buffer: like this.
>
[quoted text clipped - 9 lines]
> buffer << 456;
> //here I hope I can get "456" from buffer.str()

You should use

    buffer.str("");

to reset the contents of the buffer to an empty string.

Jonathan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.