basic_string<char_type,traits_type,allocator_type> str() const;void str (const basic_string<char_type,traits_type,allocator_type>& s);
123456789101112
// ostringstream::rdbuf #include <string> // std::string #include <iostream> // std::cout #include <sstream> // std::ostringstream int main () { std::ostringstream oss; oss << "One hundred and one: " << 101; std::string s = oss.str(); std::cout << s << '\n'; return 0; }
One hundred and one: 101