Ostrstream unpredicted behavior in VS 2008
ostrstream m_msgStream;
m_msgStream.seekp(0);
m_msgStream << "Hello";
m_msgStream << ends;
char *str = m_msgStream .str();
We are getting str NULL. If we remove th开发者_JAVA百科e skeep line then it working fine. Even the same code is working fine with VS 6. Anyidea how to use seekp in VS 2008?
ostrstream
is deprecated. Use std::ostringstream
instead.
#include <sstream>
std::ostringstream m_msgStream;
m_msgStream << "Hello";
std::string str = m_msgStream().str();
const char* cstr = str.c_str();
精彩评论