What does the C in 12 34 5C mean? I thought 12345 would be represented by hex 01 23 45. How would 123456, -12345 and -123456 be represented? Here's a function which may be helpful. You will have to modify it to handle the "C".
#include <stdio.h>
void frompd(pd,len,num)
char *pd;
int len, *num;
{
int i,j, n1;
j=1;
*num = 0;
for (i=len-1;i>=0;i--)
{
n1 = (i%2) ? pd[i/2] % 16 : pd[i/2] / 16;
*num += n1*j;
j *= 10;
}
}
main()
{
int num;
char packed[2];
packed[0] = 0x64;
packed[1] = 0x42;
frompd(packed, 4, &num);
printf("num= %d\n",num);
}