# about testing a program

• 06-08-2002
Abdi
about testing a program
Hi,

I was working on a program convert 16-HEXA-character key to be 8-ASCII-character key. apparently I am having problem for testing it because it producces strange symbols it also uses an auxilary program that converts Hex value into decimal.

Can anyone see if the way I am testing the program is correct ?

Code:

```code int main() {   int i;   ByteType y;   ByteType X [16] = "FFFFFFFFFFFFFFFF";   for( i = 0 ; i < 16; i++)   {       y = ASCIZ( &X[i]) ;       printf("the corresponding characters are %c\n", y);      } }    ByteType ASCIZ(ByteType *Addr) {         int i, v1, v2;         ByteType a1, a2, v;         /* 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; } /* there is function that converts Hex to decimal */ int Convert(ByteType val ) {   if ((val >= 0  ) && (val <= '9' ))               return val;              else ...   }```
• 06-09-2002
Zeeshan
For easy conversion to-and-from b/w number systems...use

char* itoa(int value, char *string, int radix);

where radix = number system (e.g. 16 for hex,8 for octadeci, 10 for ...)