把含一字节变量的16进制格式数据转换为字符串显示

void CPrivate::GetHexStrFromHexArray( CString &strTemp, BYTE hex ) 
{
BYTE highBye; 
BYTE lowByte= hex << 4; // 0x0b
lowByte >>= 4;

highBye = hex >> 4;// 0x0a
if ( highBye >= 0x0a && highBye <= 0xf )
{
highBye+=0x57;
}
else if ( highBye >= 0x00 && highBye <= 0x09  )
{
highBye+=0x30;
}


if ( lowByte >= 0x0a && lowByte <= 0xf )
{
lowByte+=0x57;
}
else if ( lowByte >= 0x00 && lowByte <= 0x09  )
{
lowByte+=0x30;
}


strTemp.Format( "%c%c", highBye,lowByte );
}

你可能感兴趣的:(c,byte,hex)