inline int hex_to_str(const unsigned char *hex, int hexlen, char *str, int &strlen)
{
int outhexlen = hexlen * 2 + 1;
if (strlen < outhexlen)
{
return -1;
}
strlen = outhexlen;
for (int i = 0; i < hexlen; ++i)
{
_snprintf(str + 2*i, 3, "%02X", (unsigned char)hex[i]);
}
return strlen;
}
int _tmain(int argc, _TCHAR* argv[])
{
UCHAR SigBytes[24] = {0,1,2,3,4,5,6};
char szByte[50] = {0};
int nLen = 50;
hex_to_str(SigBytes, 24, szByte, nLen);
return 0;
}
相关阅读
----把16进制字符串转换成整数