Using ostringstream causing program crash

亡梦爱人 提交于 2019-12-13 07:21:10

问题


I have some older C++ applications/services that I need to maintain which run on Windows 2003 (not by choice). I had things all set and working with VS 2013, but now I can't get any of the C++ projects working again. They just crash. I narrowed it down to when stringstream is used so I wrote a sample Win32 exe to test with.

These are the only settings I've changed in VS 2013 Update 5: Set to use Platform Toolset = Visual Studio 2013 - Windows XP (v120_xp). Character Set = Use Multi-Byte Character Set.

int _tmain(int argc, _TCHAR* argv[])
{
    ostringstream zs;
    zs << "Hello";
    string strTemp = zs.str();
    printf("%s\n", zs.str().c_str());

    return 0;
}

It crashes on zs << "Hello";


回答1:


In Visual Studio 2013 and later, the MFC libraries for multi-byte character encoding (MBCS) is provided as a seperate add-on for Visual Studio which may be downloaded from the MSDN download site.

https://msdn.microsoft.com/en-us/library/5z097dxa.aspx



来源:https://stackoverflow.com/questions/32079350/using-ostringstream-causing-program-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!