现在的位置: 首页 > 综合 > 正文

16进制转10进制

2013年08月14日 ⁄ 综合 ⁄ 共 524字 ⁄ 字号 评论关闭
    CString strInput;
   strInput="E01F3D0D0A"; // 16进制的内容
   int strlen=strInput.GetLength();
   int len2=strlen/2;
   char chTest[634];
   char *bufIn;
   bufIn=new char[strlen];
   memcpy(bufIn,(void *)(LPCTSTR)strInput,strlen);
   
   for (int j=0;j<634;j++)
   {
    if (bufIn[2*j]>96)
    {
     bufIn[2*j]-=87;
    }
    else
    {
     bufIn[2*j]-=48;
     
    }
    int nNum=bufIn[2*j]*16;
    if (bufIn[2*j+1]>96)
    {
     bufIn[2*j+1]-=87;
    }
    else
    {
     bufIn[2*j+1]-=48;
     
    }
    nNum+=bufIn[2*j+1];
    memset(chTest+j,nNum,1);
   }
   

抱歉!评论已关闭.