Thank you for your codes! I was able to C and it gave me the correct dec to hex conversion. Another question appears now.
I need to store those hex numbers of an address and put them into a variable so I can access the information at that address. But when I put the string of numbers together into a variable called 'AddString', I do not only has the hex number, but also some beginning and terminal symbols like this
0X*0|*0|*0|*0|*0| *0|*2|*5|, where the hex number is only 0X00000025. What can I do to get rid of the * and | ?
Here's my modified code for C.
int main()
{
int number=37;
int i;
char* y;
char AddString[15]="0X";
int nonzero = 0;
puts("Hex: ");
for(i = 7; i >= 0; i--)
{
nonzero += (number >> (i * 4)) & 0xF;
{
switch(((number >> (i * 4)) & 0xF))
{
case 0: y[1]='0'; puts("0");break; case 1: y[1]= '1'; puts("1");break;
case 2: y[1]= '2'; puts("2");break;
case 3: y[1]= '3'; puts("3");break;
case 4: y[1]= '4'; puts("4");break;
case 5: y[1]= '5'; puts("5");break;
case 6: y[1]= '6'; puts("6");break;
case 7: y[1]= '7'; puts("7");break;
case 8: y[1]= '8'; puts("8");break;
case 9: y[1]= '9'; puts("9");break;
case 10: y[1]='A'; puts("A");break;
case 11: y[1]='B'; puts("B");break;
case 12: y[1]='C'; puts("C");break;
case 13: y[1]='D'; puts("D");break;
case 14: y[1]='E'; puts("E");break;
case 15: y[1]='F'; puts("F");break;
default:
puts("Error, print_hex_digit accepts 0-15 only\n");
}
strcat(AddString, y);
}
}
printf("Answer is: %s\n", AddString);
return 0;
}
Thank you very much! Your help is being very appreciated!