char * HexString2BinArray(const char * s) //轉換Hex字符串到bin數組

{

char HexBuf[3];

char * result=new char[(strlen(s) /2)+1]; //定義一個長度為s一半+1的char指針

result[0]=0;//

 

int i=0;

while (strlen(s)) //設置長度的不為空

{

strncpy(HexBuf,s,2); //字串複製

HexBuf[2]=0;

result[i]=(char)strtoul(HexBuf,0,16); //返回變量的i為為轉換后的hexbuf

i++;

s+=2; //s+2

}

i++;

 

return result; //返回結果

}

 

char WildSymbolToChar(const char* x) //Wild符號轉換成char

{

char n;

 

if (x[0]=='?') //如果x[0]為'?'

n=x[1]; //n為?的第二位

else

n=x[0]; //否則就為第一位

 

if (n>='0' && n<='9') //如果n為數字

n-='0'; //

else

{

if (n>='a' && n<='f') //如果n為小寫字幕字母

n-='a';

else

{

if (n>='A' && n<='F') //如果n為大寫字母

n-='A';

}

}

if (x[1]=='?') //如果x[1]為?

n=n<<4;

 

return n;

}

arrow
arrow
    創作者介紹
    創作者 lypwell 的頭像
    lypwell

    0m的部落格

    lypwell 發表在 痞客邦 留言(0) 人氣()