#include<stdio.h> unsigned char a[100]={ 0x11,0x22,0x33 }; unsigned char Hex_To_Char(unsigned char byte) { if(byte>=0&&byte<=9) { return (byte+48); } else { return (byte+55); } } unsigned char Byte_Shift(unsigned char num ,unsigned char *p) { unsigned char a,b; a=(int)(num&0xf0)>>4;//shi wei b=(int)num&0xf; // gewei p[0]=Hex_To_Char(a); p[1]=Hex_To_Char(b); } unsigned char Hex_To_String(unsigned char *source,unsigned char *dst,int num) { unsigned char i,j; for(i=0;i<num;i++) { if(i!=0) { Byte_Shift(source[i],&(dst[i*3])); dst[i*3+2]=' '; } else { Byte_Shift(source[i],dst); dst[i+2]=' '; } } } int main() { unsigned char a=0x3f; int i,j; unsigned char hello[10]={ 0x32,0x91,0xa4,0xcf,0x98,0x6f,0xad }; unsigned char m[50]={ 0 }; for(i=0;i<sizeof(hello);i++) { Hex_To_String(hello,m,7); } printf("%s \n",m); getchar(); return 0; }