I like to use std::ostrstream to format text but not print it to stdout but instead write it into an std::string (by accessing the std::ostrstream::str() member). Apparently this is deprecated now. So, how am I supposed to write formatted objects to a string, with the same convenience as when writing to a stream?
I like to use std::ostrstream to format text but not print it to stdout
Share
You could use
std::ostringstream. Similarly, instead ofstd::istrstreamyou should usestd::istringstream. You need to include the<sstream>header for these classes.You could also see this question which explains why
strstreamwas deprecated.