I have a vector<char> of data which I want to write into std::stringstream.
I tried:
my_ss.write(vector.data(), vector.size());
…but it seems to put nothing into my_ss which I declared as follows:
std::stringstream my_ss( std::stringstream::binary);
Why write is not working (app does not crash and compiles with 0 errors, 0 warnings)?
For the “how do I do it” you can use a
std::ostream_iterator:Complete example:
You could also just use that to construct a
stringdirectly, without going via astringstreamat all: