本文主要是介绍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;
这篇关于ostrstream和ostringstream的区别的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!