oh that's really strange ! my program run with this syntax error (=+) !

I've fixed it ..

here's my program working fine.. - NOW i'm going to write the print function

by the way do you have a way to do the convert function without having these many cases !! ..

Code:
```#include <stdio.h>
#include <math.h>
#include <string.h>

unsigned long int Convert(char[], int);

int main()
{
char input[65];
unsigned long int value;
int base;
int val;

do
{
printf("Enter a positive number: ");
scanf("%64s",&input);
printf("Enter the base: ");
scanf("%d",&base);
val = Check(input,base);
if(val==1)
printf("Thanks\t:)\nThe number you've entered matches the base you've selected!\n");
else
printf("Error\t:(\nThe number you've entered doesn't match the base you've selected!\nPlease, try again..\n");
}while(val==0);

value = Convert(input,base);

//Print(value);

//printf("%lu\n", value);

return;
}

//void Print(unsigned long int value)
//{

//}
unsigned long int Convert(char input[], int base)
{
unsigned long int value;
int i;
int n;
n = 0;
value = 0;

for(i=strlen(input)-1;i>=0;i--)
{
switch(input[i])
{
case '0':
value += pow(base,n)*0;
break;
case '1':
value += pow(base,n)*1;
break;
case '2':
value += pow(base,n)*2;
break;
case '3':
value += pow(base,n)*3;
break;
case '4':
value += pow(base,n)*4;
break;
case '5':
value += pow(base,n)*5;
break;
case '6':
value += pow(base,n)*6;
break;
case '7':
value += pow(base,n)*7;
break;
case '8':
value += pow(base,n)*8;
break;
case '9':
value += pow(base,n)*9;
break;
case 'A':
value += pow(base,n)*10;
break;
case 'B':
value += pow(base,n)*11;
break;
case 'C':
value += pow(base,n)*12;
break;
case 'D':
value += pow(base,n)*13;
break;
case 'E':
value += pow(base,n)*14;
break;
case 'F':
value += pow(base,n)*15;
break;
}
n++;
}
return value;
}

int Check(char input[], int base)
{
int i;
switch(base)
{
case 2:
for(i=strlen(input)-1;i>=0;i--)
{
if(!(input[i]=='1' || input[i]=='0'))
return 0;
}
break;
case 8:
for(i=strlen(input)-1;i>=0;i--)
{
if(input[i]<'0' || input[i]>'7')
return 0;
}
break;
case 8:
for(i=strlen(input)-1;i>=0;i--)
{
if(input[i]<'0' || input[i]>'7')
return 0;
}
break;
case 10:
for(i=strlen(input)-1;i>=0;i--)
{
if(input[i]<'0' || input[i]>'9')
return 0;
}
break;
case 16:
for(i=strlen(input)-1;i>=0;i--)
{
if(input[i]<'0' || (input[i]>'9' && input[i]<'A') || input[i]>'F')
return 0;
}
break;
}
return 1;
}```

Last edited by shabbir; 22Jul2007 at 10:16.. Reason: Code block - http://www.go4expert.com/forums/misc.php?do=bbcode#code