代码如下,最后输出的数组output[]就是你想要的结果:unsigned char ConvertCharToHex(char ch){ if ((ch >= '0') &&(ch <= '9')) { return (ch-'0'); } else if ((ch >= 'A') &&(ch <= 'Z')) { return ((ch-'A')+0x0A); } else if ((ch >= 'a') &&(ch <= 'z')) { return ((ch-'a')+0x0A); }return 0;}int main() { char *mac="0007A8B398E4"; unsigned char output[100]={0}; int i; for(i=0; i<(strlen(mac)/2); i++) { output[i] = (ConvertCharToHex(mac[i*2])<<4); output[i] += ConvertCharToHex(mac[i*2+1]); printf("%02X,", output[i]); }}