Link to home
Start Free TrialLog in
Avatar of bormuth
bormuth

asked on

reset a stringstream


Is it possible to reset a stringstream so that it is empty afterwards.

   stringstream s;
   s << "Hello";
   s.reset();           // <-- HOW TO DO THIS
   std::cout s.str();   // <-- Should print NOTHING


(Even s = stringstream() doesn't work).
Avatar of Axter
Axter
Flag of United States of America image

Try s = stringstream("");

Example:
int main()
{
     stringstream s;
     s << "Hello";
     s = stringstream("");
     std::cout << s.str();   // <-- Should print NOTHING
     return 0;
}
Avatar of bormuth
bormuth

ASKER


Axter:

There is no asignment operator for stringstream...


Error E2285: Could not find a match for 'stringstream::operator =(stringstream)'
What compiler are you using?
Avatar of bormuth

ASKER


Borland C++ 5.5.1 for Win32
>>There is no asignment operator for stringstream...

There is an assignment operator in VC++.
ASKER CERTIFIED SOLUTION
Avatar of thienpnguyen
thienpnguyen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bormuth

ASKER



Yea ... that's great !!!

           Thanks ....