如何将一个字符串转化为相应的十六进制acsii码串
int main(int argc, char* argv[])
{
const char* pt = "ABC";
const char* p = pt;
char sz[1024]={0};
char temp[4]={0};
char x;
while( 0 != *p ){
x = *p;
sprintf(temp,"%x" , x );
strcat(sz, temp);
p++;
}
printf("%s\n",sz);
return 0;
}
------------------
用itoa也可以
int main()
{
char *a ="AB";int i=0;
char out[20]={0};
char temp[10]={0};
while(a[i]!=0)
{
itoa(a[i],temp,16);
i++;
strcat(out,temp);
}
printf("%s\n",out);
return 0;
}