I am looking to develop a function that converts a series of ASCII characters (in their respective hex representation) to a single hex value. For example, an input string to this function may be {0x46 0x32 0x3A 0x42} (or {F 2 0 B} in ASCII), the needed output would be a single integer hex value 0xF20B.
I've tried using type casting, sprintf, and bit operations to develop a function that would do this without success. An approach that I believe would work would be type casting each ASCII Hex value to a char, concatenating them, then converting the string to a single Hex value.
C does have the stdlib.h atof function that converts the input character string to a double precision floating point value. However, this function does not accept characters and so Hex A - F values would not be properly converted.
Thank you in advance for any input.
You can write it yourself:
https://godbolt.org/z/9s6xn33s8