首页 > 代码库 > C++

C++

BYTE AscllToBinary(char ctemp)
{
BYTE result = 0xff;
if (ctemp >= ‘0‘ && ctemp <= ‘9‘)
{//‘0‘-‘9‘ 之间的ascll字符
result = ctemp - ‘0‘;
return result;
}

if (ctemp >= ‘A‘ && ctemp <= ‘F‘)
{//‘0‘-‘9‘ 之间的ascll字符
result = ctemp - ‘A‘ + 10;
return result;
}

if (ctemp >= ‘a‘ && ctemp <= ‘f‘)
{//‘0‘-‘9‘ 之间的ascll字符
result = ctemp - ‘a‘ + 10;
return result;
}
cout<<"字符不是有效的字符十六进制数\n";
//TRACE("字符不是有效的字符十六进制数\n");
return result;//返回ff代表出错了
}

C++