Or ostringstream?
istringstream a("asd");
istringstream b = a; // This does not work.
I guess memcpy won't work either.
Or ostringstream?
istringstream a("asd");
istringstream b = a; // This does not work.
I guess memcpy won't work either.
You can't just copy streams, you have to copy their buffers using iterators. For example:
#include <sstream>
#include <algorithm>
......
std::stringstream first, second;
.....
std::istreambuf_iterator<char> begf(first), endf;
std::ostreambuf_iterator<char> begs(second);
std::copy(begf, endf, begs);
istringstream a("asd");
istringstream b(a.str());
Edit: Based on your comment to the other reply, it sounds like you may also want to copy the entire contents of an fstream into a strinstream. You don't want/have to do that one character at a time either (and you're right -- that usually is pretty slow).
// create fstream to read from
std::ifstream input("whatever");
// create stringstream to read the data into
std::istringstream buffer;
// read the whole fstream into the stringstream:
buffer << input.rdbuf();