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;
}

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-08-06
  • 2021-12-19
  • 2022-12-23
  • 2021-10-07
猜你喜欢
  • 2022-12-23
  • 2021-11-17
  • 2021-09-04
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案