I have a string of characters, each of which is a hexadecimal value, for example:
unsigned char msg[] = "04FF";
I would like to store "04" in bytes and FF in another byte?
The output of desire should be like this,
unsigned short first_hex = 0x04;
unsigned second_hex = 0xFF;
memcpy(hex_msg_p, &first_hex,1);
hex_msg_p++;
memcpy(hex_msg_p, &second_hex,1);
hex_msg_p++;
My line is very long and I really want to automate the process.
Thanks in advance
source
share