宽字符的CString转换为constchar*
来源:优易学  2011-12-6 11:44:37   【优易学:中国教育考试门户网】   资料下载   IT书店
  一、
  使用函数_tcscpy_s:
  CString theString( "This is a test" );
  int sizeOfString = (theString.GetLength() + 1);
  LPTSTR lpsz = new TCHAR[ sizeOfString ];
  _tcscpy_s(lpsz, sizeOfString, theString);
  最后再转换一下lpsz为const型的
  LPTSTR在UNICODE环境下编译青年人网提示是whca_t类型
  二、
  CString str = _T("Hello World!");
  char szStr[256] = {0};
  wcstombs(szStr, str, str.GetLength());
  const char * p = szStr;

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训