/* * 函数名: CString2Char * 参数1: CString str 待转换字符串 * 参数2: char ch[] 转换后将要储存的位置 * 将Unicode下的CString转换为char* */voidCString2Char(CString str,charch[]){ int
i; char
*tmpch; intwLen = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL,
0, NULL, NULL);//得到Char的长度 tmpch =newchar[wLen
+ 1]; //分配变量的地址大小 WideCharToMultiByte(CP_ACP, 0, str, -1, tmpch, wLen, NULL, NULL); //将CString转换成char* for(i = 0; tmpch[i] !='\0';
i++) ch[i] = tmpch[i]; ch[i] ='\0';}
本文介绍了一个将Unicode下的CString转换为char*的函数实现过程,包括使用WideCharToMultiByte函数进行转换,并详细解释了每个步骤的作用。

1290

被折叠的 条评论
为什么被折叠?



