Call a function returns the hexadecimal data not return a string, can you tell me how to achieve?
CodePudding user response:
Is to convert hexadecimal string to integer array? Read characters from a string once and then converted to a decimal lineCodePudding user response:
Unsigned char * __fastcall StrToHex (const AnsiString& HexStr)
{
Unsigned char * result=new unsigned char (hexStr. The Length ()/2);
Unsigned char * pbufs=the result;
Char * pData=(https://bbs.csdn.net/topics/hexStr.UpperCase). C_str ();
for(int i=0; i{
Unsigned char val=pData [I] - '0';
If (val & gt; 0 xf)
Val -=7;
If (I % 2==0)
{
* pbufs=val.
* pbufs & lt; <=4;
}
The else
{
* pbufs |=val;
PBuf++;
}
}
return result;
}
Pay attention to release the returned data buffer,