Click to See Complete Forum and Search --> : char to hex


applesplatter
May 21st, 2002, 06:57 AM
I have a char string called buf[2]. buf[0] and buf[1] are not characters, but hexadecimal numbers that I need to extract. Lets say, buf[0] = 0x02 and buf[1] = 0x70. How can I put these two numbers together (to form the hex number 0x0270) to form an int value?? Thanks.

AlanGRutter
May 21st, 2002, 07:29 AM
Try

int lResult = (Buf[0] << 8) + Buf[1];

Regards
Alan

applesplatter
May 21st, 2002, 07:34 AM
It Worked!! Thanx