C++ ASCIIToBinary
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代表出错了
}
博客内容只为本人学习所感转载亦或自写,不足或错误之处请大家不吝赐教