一个HexToInt的C/C++函数

int  BetterVenca25(char* hex)
{
   int res=0;
   for(;*hex;hex++)
   {  int d=toupper(*hex);
      if(d >='0' && d <='9')d-='0';
      else
      if(d >='A' && d <='F')d-='A'-10;
      else  return -1;              
      res=res*16+d;
   }
   return res;
}
 

原文地址:https://www.cnblogs.com/lidabo/p/4012274.html