MSDN2005上有下面的一段程序:
#define BUFFER_SIZE 100
size_t i;
char* pMBBuffer = (char *)malloc( BUFFER_SIZE );
wchar_t* pWCBuffer = L "Hello, world. ";
// Conversion
wcstombs_s(&i, pMBBuffer, (size_t)BUFFER_SIZE,
pWCBuffer, _TRUNCATE/*(size_t)BUFFER_SIZE */);
// Free multibyte character buffer
if (pMBBuffer)
{
free(pMBBuffer);
}
运行到这里,设置一个断点,结果i等于14(正确),而pMBBuffer为 " "
不知道为什么?
如果改为:
wchar_t* pWCBuffer = L "我爱你Hello, world. ";
则i等于0, pMBBuffer为 " ",哪位能解释一下问题出在哪里?
------解决方案--------------------------------------------------------