问题
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