当前位置: 代码迷 >> WinCE >> 怎么将 CString 转换为 char * ?
  详细解决方案

怎么将 CString 转换为 char * ?

热度:593   发布时间:2016-04-28 13:30:29.0
如何将 CString 转换为 char * ??
谢谢

------解决方案--------------------
可以直接转: char* p = (char*)(const char*)str;
------解决方案--------------------
可以使用函数:wcstombs() ,完成转换。
------解决方案--------------------
MSDN:
wcstombs
Converts a sequence of wide characters to a corresponding sequence of multibyte characters.
Parameters
mbstr
The address of a sequence of multibyte characters
wcstr
The address of a sequence of wide characters
count
The maximum number of bytes that can be stored in the multibyte output string
Return Value
If wcstombs successfully converts the multibyte string, it returns the number of bytes written into the multibyte output string, excluding the terminating NULL (if any). If the mbstr argument is NULL, wcstombs returns the required size of the destination string. In versions of Windows CE prior to 3.0, setting mbstr to NULL returns -1. If wcstombs encounters a wide character it cannot be convert to a multibyte character, it returns –1 cast to type size_t.


  相关解决方案