#include <stdio.h>
#include <string.h>
unsigned long f(char* str)
{
unsigned long var=0;
unsigned long t;
int len = strlen(str);
if (var > 8) //最长8位
return -1;
strupr(str);//统一大写
for (; *str; str++)
{
if (*str>=‘A‘ && *str <=‘F‘)
t = *str-55;//
else
t = *str-48;
var<<=4;
var|=t;
}
return var;
}
void main()
{
printf("%x\n", f("FE80搜索"));
}
时间: 2024-10-14 21:53:51