ostrstream和ostringstream的区别

1. string stream classes
<sstream>
basic_istringstream, 特化版本istringstream, wistringstream
basic_ostringstream, 特化版本ostringstream, wostringstream
basic_stringstream, 特化版本stringstream, wstringstream
basic_stringbuf<>, 特化版本stringbuf, wstringbuf


2.
 char* stream classes
<strstream>
istrstream
ostrstream
strstream
strstreambuf

ostrstream::str()返回的是char*
ostringstream::str()返回的是std::string

打印ostrstream::str()之前别忘了在最后添加std::ends或者'{post.content}',
std::ostrstream buffer;
buffer << "float x: " << x << std::ends;
char* s = buffer.str();
cout << s << std::endl;

你可能感兴趣的:(java)