hello i have an array of 3 bytes unsgined char and i want to convert the 3 byte (hex) array to 1 byte (hex value). values in the array are between 0 - 9 only.
unsigned char buf[3], output; buf[0] = 0x01; buf[0] = 0x02; buf[0] = 0x03;
i want an output as follow: 123 in HEX => output = 0x7B
i tried 'sscanf' and i haven't succeeded. please help.
123 in HEX => output = 0x7B
That makes no sense at all. There's absolutely nothing "HEX" about a "123". That's decimal or text, depending on whether by '2' you mean a byte valued exactly 2, or a byte with the character code for '2'.
From his example soruce, you can see that he means the numeric value 2, not the ASCII character 2.
Byt three bytes with the range 0..9 in them can still form any value up to 999 which is almost four times the capacity of a single byte.