像这一种数据格式的字符串怎么转换,因为这一段需要动态调用。在网上找了好多没找到解决方法,求帮助
我自己写了个函数解决了,效果图
void* Buf16ToMem16(string sBuf)
{
string strBuf = sBuf;
string strtmp ;
DWORD dwSt=0,dwEd=0,dwCount=0,dwStrSz = 0;
BYTE* bTmp = new BYTE{0};
void* TmpVoid;
void* RetVoid;
dwStrSz = strBuf.size();
dwSt = strBuf.find("\\", dwSt ? dwSt + 1 : 0);
TmpVoid = new char[dwStrSz] {0};
while (true)
{
dwEd = strBuf.find("\\", dwSt + 1);
strtmp = strBuf.substr(dwSt + 1, (dwEd - dwSt - 1));
sscanf_s(strtmp.c_str(), "x%x", &bTmp);
memcpy_s((char*)TmpVoid +dwCount, 1, &bTmp, 1);
if (dwEd == string::npos)
{
break;
}
++dwCount;
dwSt = dwEd;
}
RetVoid = new char[dwCount + 1]{0};
memcpy_s(RetVoid, dwCount + 1, TmpVoid, dwCount + 1);
delete TmpVoid;
TmpVoid = NULL;
return RetVoid;
}
CSDN现在搞得图片分辨率太低了点,看不清楚啊。