Here is my code that does the conversion from hex to decimal. Hexadecimal values are stored in an unsigned array of char:
int liIndex ;
long hexToDec ;
unsigned char length[4];
for (liIndex = 0; liIndex < 4 ; liIndex++)
{
length[liIndex]= (unsigned char) *content;
printf("\n Hex value is %.2x", length[liIndex]);
content++;
}
hexToDec = strtol(length, NULL, 16);
Each element of the array contains 1 byte of information, and I read 4 bytes. When I completed it, here is the result that I get:
Hex value is 00
Hex value is 00
Hex value is 00
Hex value is 01
Chunk length is 0
Can someone help me understand the error here. The decimal value must be 1 instead of 0.
Regards, Darkie
source
share