开发者

Ostrstream unpredicted behavior in VS 2008

开发者 https://www.devze.com 2023-02-10 04:48 出处:网络
ostrstreamm_msgStream; m_msgStream.seekp(0); m_msgStream << \"Hello\"; m_msgStream << ends; char *str = m_msgStream .str();
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();
0

精彩评论

暂无评论...
验证码 换一张
取 消