making stringstream empty

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

    making stringstream empty

    Hi,
    I am using a variable of type stringstream in my application. I
    am adding some information in the stream. I would like to know what is
    the method to make the stream empty. Thanx in advance.






  • =?GB2312?B?yrGzvc6w?=

    #2
    Re: making stringstream empty

    On 2ÔÂ21ÈÕ, ÏÂÎç5ʱ20·Ö, mthread <rjk...@gmail.c omwrote:
    Hi,
    I am using a variable of type stringstream in my application. I
    am adding some information in the stream. I would like to know what is
    the method to make the stream empty. Thanx in advance.
    you can use clear() method to make the stream empty.

    Comment

    • kasthurirangan.balaji@gmail.com

      #3
      Re: making stringstream empty

      On Feb 21, 2:20 pm, mthread <rjk...@gmail.c omwrote:
      Hi,
           I am using a variable of type stringstream in my application. I
      am adding some information in the stream. I would like to know what is
      the method to make the stream empty. Thanx in advance.
      use str member function.

      #include <sstream>

      main()
      {
      std::stringstre am sstr;
      sstr << "hello";
      sstr.str("");
      }

      Thanks,
      Balaji.

      Comment

      • Richard Herring

        #4
        Re: making stringstream empty

        In message
        <ccaa3c01-7313-4ed0-8b4b-34afc582ba26@t6 6g2000hsf.googl egroups.com>,
        =?GB2312?B?yrGz vc6w?= <shichenweixjtu @gmail.comwrite s
        >On 2ÔÂ21ÈÕ, ÏÂÎç5ʱ20·Ö, mthread <rjk...@gmail.c omwrote:
        >Hi,
        > I am using a variable of type stringstream in my application. I
        >am adding some information in the stream. I would like to know what is
        >the method to make the stream empty. Thanx in advance.
        >
        >you can use clear() method to make the stream empty.
        No, you can't. clear() clears the iostate flags. str("") makes it empty.

        --
        Richard Herring

        Comment

        • Joe Greer

          #5
          Re: making stringstream empty

          "=?GB2312?B?yrG zvc6w?=" <shichenweixjtu @gmail.comwrote in news:ccaa3c01-
          7313-4ed0-8b4b-34afc582ba26@t6 6g20...l egroups.com:
          On 2ÔÂ21ÈÕ, ÏÂÎç5ʱ20·Ö, mthread <rjk...@gmail.c omwrote:
          >Hi,
          > I am using a variable of type stringstream in my application. I
          >am adding some information in the stream. I would like to know what is
          >the method to make the stream empty. Thanx in advance.
          >
          you can use clear() method to make the stream empty.
          It sure sounds like that's what it should do, doesn't it? Too bad it
          really only clears some flags. str("") is the way to reset the string.

          Comment

          • Jeff Schwab

            #6
            Re: making stringstream empty

            mthread wrote:
            Hi,
            I am using a variable of type stringstream in my application. I
            am adding some information in the stream. I would like to know what is
            the method to make the stream empty. Thanx in advance.
            ss.str(std::str ing());

            Comment

            Working...