Question about hexadecimal

Hello guys,

I got "3838" as String. Like :

String example = "3838";

Which is equal to ( 88 ) as a hexadecimal. ( I converted here : Convert hexadecimal to text - Converters )

But I need to use it as a char like here :

char data[] = {0x88};

How can I do this ? Sorry for bad expression. Thank you very much.

char data[] = {0x88};It doesn't make much sense (to me at least) to have a single element array.

AWOL:
char data[] = {0x88};It doesn't make much sense (to me at least) to have a single element array.

Yeah,

It's actually something like this :

char data[] = {0x88,0x0f,0xc7,0xae,0x76,0x85,0xe9,0xb1,0x8f,0x2f,0x2a,0xd3,0x60,0x37,0x6b,0x6d};

Why are you starting with a String?

It's about my code but I can't change it. I actually have "14392" decimal value which is equal to hexadecimal "3838". So It works if I can convert decimal 14392 to char 0x88.

Thank you very much.

0x38 is the ASCII representation 0f '8'. to convert to an integer:

split your string into the two separate numbers "38" and "38" and then use strtol(string, NULL, 16) to convert them to integers. You can then use

(int_msb - '0') * 16 + (int_lsb - '0') to convert it to a standard int.

I don't know how you got "3838", but it seems that it would be easier to do your conversion before that string is created when you get the ASCII '8'.

I actually have "14392" decimal value

No, you have a binary value.
Simple mask and shift software will sort that out in no time.
If that scares you, lowByte and highByte will help.

Thanks for sharing, though I have no idea what that has to do with the OP.