Hex to Ascii/Integer
Posted on 1998-05-20
(C on Solaris 2.x)
I'm having problems on how to store some Hex values.
Hopefully you can help this newbie in C.
First of all, here're 2 simple variables I'm having ...
unsigned char *source, *dest;
After I read in a string e.g. "12AB" into source, I convert the string into Hex and put the output into dest :
< ..read string "12AB" from file into source ...>
AsciiToHex(source, strlen(source), dest);
Now the problem is I need to store the decimal value of hex '12' (which is 1x16 + 2 = 18) and similarly that of 'AB' (which is 10x16+11=171) into 2 separate ascii strings :
unsigned char *var1, *var2;
so that var1 contains "18" and var2 has "171" in ascii.
How do I do that ?
Thanks for helping !!!!!