really got stuck with unsigned chars
Hi,
I have program that converts 16 hex chars to 8-ascii characters
while testing, i have noted that the program generates a large unsigned chars figures such 266,239, 160...
How can I get the corresoonding ascii characters from above unsigned chars ?
here is the snippet:
Code:
code
/* prototype */
ByteType ASCIZ(ByteType *Addr);
ByteType ASCIZ(ByteType *Addr)
{
int i, v1, v2;
ByteType a1, a2, v,y;
/* Convert 16-HEXA-character key to be 8-ASCII-character key. */
for (i = 0; i < 8; i++)
{
a1 = *Addr++;
if (i == 7)
a2 = *Addr;
else
a2 = *Addr++;
/* Convert two HEXA characters into their decimal value. */
v1 = Convert(a1);
v2 = Convert(a2);
/* Convert the two decimal value to be one ASCII character. */
v = ((v1 * 16) + v2);
}
return v;
}
int Convert(ByteType val )
{
if ((val >= 0 ) && (val <= '9' ))
return val;
else ...
}
Re: really got stuck with unsigned chars
Quote:
Originally posted by Abdi
i have noted that the program generates a large unsigned chars figures such 266,239, 160...
Unsigned char is 8 bits (0-255)...