Cstring转换 const char* 出错

来源:互联网 发布:数据挖掘工具有哪些 编辑:程序博客网 时间:2024/05/21 17:28

Cstring转换 const char* 出错

法2://UNICODE模式下,把CString转换为Char

         CString str = this->mSourceFile;

              wchar_t*wchar;

              wchar= str.GetBuffer();

              str.ReleaseBuffer();

              size_tconvertedChars = 0;

              size_tsizeInBytes = ((str.GetLength()+1)*2);

              char*ch = (char*)malloc(sizeInBytes);

              wcstombs_s(&convertedChars,ch,sizeInBytes,wchar,sizeInBytes);