Home  >  Q&A  >  body text

hex - What is a better way to convert C++ decimal int to hexadecimal char?

What is a better way to convert C++ decimal int to hexadecimal char?

UPDATE:
For example, 17 I hope that the result after the change is char(0x00) char(0x11)
but not "11" char("1") char ("1")

怪我咯怪我咯2686 days ago640

reply all(2)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 13:28:20

    A friend who is engaged in embedded technology recommended a method

    x & 0xFF; x >> 8

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 13:28:20

    int a=11123456;
    char str[20]={0};
    sprintf(str, "%x", a);

    reply
    0
  • Cancelreply