首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > WinCE >

怎么将 CString 转换为 char * ?

2012-03-20 
如何将 CString 转换为 char * ??谢谢[解决办法]可以直接转: char* p (char*)(const char*)str[解决办

如何将 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.


热点排行