basic_string<char_type,traits_type,allocator_type> str() const;void str (const basic_string<char_type,traits_type,allocator_type>& s);
1
2
3
4
5
6
7
8
9
10
11
12
// stringstream::str
#include <string> // std::string
#include <iostream> // std::cout
#include <sstream> // std::stringstream, std::stringbuf
int main () {
std::stringstream ss;
ss.str ("Example string");
std::string s = ss.str();
std::cout << s << '\n';
return 0;
}
Example string