Re: How to flush the ostringstream buffer?

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

From: Jonathan Turkanis (technews_at_kangaroologic.com)
Date: 07/08/04

  • Next message: Jason Winnebeck: "Re: Microsoft & GNU c++ compiler"
    Date: Wed, 7 Jul 2004 22:33:29 -0600
    
    

    "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()
    >

    You should use

         buffer.str("");

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

    Jonathan


  • Next message: Jason Winnebeck: "Re: Microsoft & GNU c++ compiler"

    Relevant Pages

    • Re: Spurious Data returned from empty db column...
      ... are an empty string, rather than setting them to null. ... So I just ran it twice, the first time Value when assigned with Buffer was ... When you retrieve a null value, does GetValue ...
      (alt.comp.lang.borland-delphi)
    • Re: set char to empty
      ... >>if you want to initialize it to an empty string. ... >> Thou shalt not assign pointer values to chars. ... After strcat to test buffer in this process, ...
      (comp.lang.c)
    • Re: How to reclaim memory without GC.start
      ... while STDIN.read(1024, buffer) ... What's the point of initializing the buffer with 1024 characters, ... instead of just initializing it with an empty string? ... read up to limit chars right away. ...
      (comp.lang.ruby)
    • Re: How to reclaim memory without GC.start
      ... while STDIN.read(1024, buffer) ... What's the point of initializing the buffer with 1024 characters, ... instead of just initializing it with an empty string? ...
      (comp.lang.ruby)
    • Re: How to flush the ostringstream buffer?
      ... > ostringstream buffer; ... to reset the contents of the buffer to an empty string. ...
      (microsoft.public.vc.language)