I'm trying to find out how can i create an IF() command to check in the argument that the user had entered is an hexadecimal number...any suggestions?Thank you
the hard part about that is '11' could be eleven in decimal or seventeen in hex. You can check for the prefix like 0x11 the '0x' means the number following is hex.
11 could be n+1 in any base n. Because every base is base 10 :).
I don't really see a problem there. If you ask for a hex number, treat it as a hex number.
int main(int argc, char *argv[])
{
int param1,i,j;
char var[]
if (argc==1)
{
if (param1.. ) // Here is where i need your help !!!! !!! <<<<<<<<<<<<<<<<<<
{
param1=atoi(argv[1]);
itoa(param1,var,16);
printf("Your deciminal number is %s\n",var);
@ hamsterman: I needed a double take but I got that one! Great joke, I'll have to steal it from you.
@ OP: Unfortunatly there is no lib to read the idiot users mind, you just have to tell them to do something (like format their input properly) and hope that they actually do it right.
@ CreativeMFS: Every numerical system "promotes" after what it would see as the 10th integer. So for decimal it's 0 - 9 (10 ints, represented by the multi-character set "10") for hex it's 0-F (16 ints, but still represented by the multi-character set "10").