static INT_PTR StatusName(CString csTxt)
{
CString csTemp;
csTemp = csTxt;
char * pchar = new char [csTemp.GetLength()*2 + 1];
memset(pchar, 0, csTemp.GetLength()*2+ 1);
WideCharToMultiByte( CP_ACP, 0, csTemp, -1, pchar, csTemp.GetLength()*2 + 1, NULL, NULL );
unsigned char buf1[2];
buf1[0] = pchar[1];
buf1[1] = pchar[0];
short iAsccii = 0;
memcpy(&brt,buf1,2);
delete [] pchar;
pchar = NULL;
return (INT_PTR)iAsccii;
}
测试环境:VC2010
本文介绍了一个C++函数,用于将字符串转换为ASCII,并返回首字母。通过使用WideCharToMultiByte和memcpy函数,实现了字符串到ASCII的转换,并通过简单的内存操作获取了首字母。
2118

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



