Although you haven't provided any code yet, it looks like you probably just wrote:
std::stringstream my_ss (std::stringstream::binary);
If you want to write a string stream, you need to combine the std::stringstream::out flag in the constructor. If I am right, then you will see that everything is working fine, if you changed this to:
std::stringstream my_ss (std::stringstream::out | std::stringstream::binary);
(Obviously, if you want to read from this string stream, you need to add std::stringstream::in )
UPDATE Now that you have your code ... yup, this is your specific problem. Please note that @awoodland indicates that you can simply build a string from a character vector instead (if this is the only thing you planned to do with this thread.)
source share