W
Woodster
I am using std::stringstream to format a string. How can I clear the
stringstream variable I am using to "re use" the same variable?
Eg:
Using std::string
std::string buffer;
buffer = "value1" + " : " + "value2";
buffer = "value3" + " : " + "value4";
Gives values of
value1 : value2
value3 : value4
The = operator for std::string overwrites the preivous contents of the
string, but I have been unable to locate a similar thing for
std:stringstream
using std::stringstream
std::stringstream buffer;
buffer << "value1" << " : " << "value2";
buffer << "value3" << " : " << "value4";
Gives values of
value1 : value2
value1 : value2value3 : value4
Which is not the desired result. How should I go about clearing the
buffer of a std::stringstream?
Thanks in advance
stringstream variable I am using to "re use" the same variable?
Eg:
Using std::string
std::string buffer;
buffer = "value1" + " : " + "value2";
buffer = "value3" + " : " + "value4";
Gives values of
value1 : value2
value3 : value4
The = operator for std::string overwrites the preivous contents of the
string, but I have been unable to locate a similar thing for
std:stringstream
using std::stringstream
std::stringstream buffer;
buffer << "value1" << " : " << "value2";
buffer << "value3" << " : " << "value4";
Gives values of
value1 : value2
value1 : value2value3 : value4
Which is not the desired result. How should I go about clearing the
buffer of a std::stringstream?
Thanks in advance