I am struggling to get a string to be understood as a hexstring during processing. I am writing a small program where I get an input ascii text as a hex string.
That is i read:
char *str = "313233";
This is actually 0x31, 0x32 and 0x33 which is actually the string "123".
I need an unsigned char array as follows:
unsigned char val[] = {0x31, 0x32, 0x33};
When I tried sscanf or sprintf, they expect integer array to be the destination pointer :(
That is, something like:
sprintf(str, "%2x", &val[0]);
How to do this? Perhaps this is very trivial but somehow I am confused.
Thanks.