basic_stringstream::str

To return or assign the basic_string object stored in the buffer.

  basic_string<charT> str() const;
  void str(const basic_string<charT> &s);  
Remarks

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.

See Also

basic_stringbuf::str()

basic_ostringstream.str()

basic_istringstream::str()

Listing: Example of basic_stringstream::str() usage
#include <iostream>
#include <sstream>

std::string buf = "CodeWarrior - \"Software at Work\"";
char words[50];

int main()
{
using namespace std;
   stringstream iost(buf, ios::in);
   cout << iost.str();
   return 0;
}

Result

  CodeWarrior - "Software at Work"