wcstombs_s 的一个问题
这是在VS2008 下面的代码:问题如下
//m_csCurrentDir 是 CString 的类型 里面是我的文件目录的字符串:例如E:\FunshionMedia\字典情人\字典情人C.rmvb"
const size_t strSize = (m_csCurrentDir.GetLength()+1)*2;
char * pstr = new char[strSize];
size_t sz=0;
wchar_t *pSctring = m_csCurrentDir.GetBuffer() ;
errno_t test = wcstombs_s(&sz,pstr,strSize,pSctring, strSize);
switch(test)
{
case 0:
MessageBox(L"成功"); break;
case EINVAL:MessageBox(L"mbstr is NULL and sizeInBytes > 0 ; or "
L"wcstr is NULL");
break ;
case ERANGE:MessageBox(L"The destination buffer is too small"
L" to contain the converted string "
L"(unless count is _TRUNCATE; see Remarks below)");
break ;
case EILSEQ: MessageBox(L"Illegal byte sequence");break ; //这是返回的
default:
MessageBox(L"wcstombs_s未成功!");
};
//这个函数没有正确执行 wcstombs_s 返回值是42MSDN上说Illegal byte sequence
//请问我这么办!我试了好多方法了,就是没办法把 CString 的字符串转换到const char * 类型
//转换要么就剩一个字符了!!!求解决方法