To return or assign the basic_string object stored in the buffer.
basic_string<charT> str() const; void str(const basic_string<charT> &s);
The function str() freezes the buffer then returns a basic_string object.
The function str(const string s) assigns the value of the string `s' to the stringbuf object.
The no argument version returns a basic_string if successful. The function with an argument has no return.
basic_stringbuf::str()
basic_ostringstream.str()
basic_stringstream::str()
#include <iostream> #include <sstream> std::string buf = "CodeWarrior - \"Software at Work\""; int main() { using namespace std; istringstream istr(buf); cout << istr.str(); return 0; }
Result:
CodeWarrior - "Software at Work"