how to clear a sstreeam object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles Herman

    how to clear a sstreeam object

    I create a ostringstream object, and use it to write to. After having done
    this, I want to re-use it, but first I need to clear out all characters in
    it. How do I do this?

    -charles

  • Mike Wahler

    #2
    Re: how to clear a sstreeam object

    "Charles Herman" <spam@no.spam > wrote in message
    news:3f70be20_2 @127.0.0.1...[color=blue]
    > I create a ostringstream object, and use it to write to. After having[/color]
    done[color=blue]
    > this, I want to re-use it, but first I need to clear out all characters in
    > it. How do I do this?[/color]

    ostringstream oss;
    oss << "blah";
    oss.str("");

    -Mike


    Comment

    • Frank Schmitt

      #3
      Re: how to clear a sstreeam object

      Charles Herman <spam@no.spam > writes:
      [color=blue]
      > I create a ostringstream object, and use it to write to. After having done
      > this, I want to re-use it, but first I need to clear out all characters in
      > it. How do I do this?[/color]

      use the str() member function:

      ostringstream os;
      os << "bla";
      os.str(""); // assign empty string to os

      HTH & kind regards
      frank

      --
      Frank Schmitt
      4SC AG phone: +49 89 700763-0
      e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com

      Comment

      Working...