Hi,
I am trying to write a program to convert Hex to Bin. I found a useful piece of code on these forums to do just that except I have one problem. I want the user to enter a hex value, not have it defined:
Code:
int funcHextoBin()
{
char *userhexd;
//char *userhexd = "92C3";
char hex[] = "0123456789ABCDEF";
char *bin[] = { "0000", "0001", "0010", "0011", "0100", "0101",
"0110", "0111", "1000", "1001", "1010", "1011",
"1100", "1101", "1110", "1111" };
printf("Hex to Bin!\n");
printf("Enter a Hexadecimal: \n");
scanf("%s", userhex);
//printf("You entered: %s\n", userhex);
*userhexd = &userhex;
while(*userhexd)
{
printf("%s", bin[strchr(hex, *userhexd)-hex]);
userhexd++;
}
putchar('\n');
system("PAUSE");
return 0;
}
As you can see the original code had *userhexd with a predefiend value. All I want to change is so that the user enters a vlue. However right now the progrma crashes with a warning "assingment makes integer from pointer without a cast" I believe the problem is "*userhexd = &userhex;" Is there any special way I can assign the user's value to *userhexd?
Thanks.