1// stringstream::str
2#include <string> // std::string
3#include <iostream> // std::cout
4#include <sstream> // std::stringstream, std::stringbuf
5
6int main () {
7 std::stringstream ss;
8 ss.str ("Example string");
9 std::string s = ss.str();
10 std::cout << s << '\n';
11 return 0;
12}
1#include <fstream>
2#include <string>
3#include <iostream>
4
5int main()
6{
7 std::string input;
8 std::cin >> input;
9 std::ofstream out("output.txt");
10 out << input;
11 out.close();
12 return 0;
13}
1// EXAMPLE
2ostringstream ssTextAsStream("This is part of the stream."); // declare ostringstream
3string sTextAsString = ssTextAsStream.str(); // converted to string
4cout << sTextAsString << "\n"; // printed out
5
6/* SYNTAX
7<YourStringStream>.str()
8*/
9
10/* HEADERS
11#include <iostream>
12#include <sstream>
13using namespace std;
14*/