BOOL CStringToByte(CString scrData,int lengh)
{
BYTE data[lengh] = new BYTE();
for (int i = 0;i < lengh; i++)
{
CString temp;
int slengh = 0;
temp = scrData.Mid(0,1);
slengh = scrData.GetLength();
scrData=scrData.Right(slengh-1);
data[i] =(BYTE) _tcstoul(temp,NULL,16);//字符转为16进制
}
return TRUE;
}
c++ MFC CString 字符串转BYTE数组
这篇文章详细描述了一个C++函数BOOLCStringToByte,它将输入的CString类型的字符串逐字符转换为16进制的BYTE数组。函数通过切割字符串、获取长度并进行字符到16进制的转换实现此功能。
430

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



