Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   HELP...Urgent!! (http://www.go4expert.com/forums/helpurgent-t7272/)

johnd 13Nov2007 10:40

HELP...Urgent!!
 
ok, im new to c programming and stuff so yea...anywayz...i need help making this function compile... whenever i compile it i keep getting an error saying " [Warning] converting to `int' from `double' "

Code:

int ToBaseTen ( char value [256], int base, int l)
{
    int result=0;
    int ivalue=0;
    int n=0;
    int j=l-1;
    char chold=0;
 
   
    while (j>0)
{
    chold=value[n];
    ivalue=atoi(&chold);
  result=result+(ivalue*pow(base,j));
    ++n;
    --j;
}
    return result;
}

thats the function..it is suppose to convert any value from another base to base ten. (not sure if it will work tho)!!


thnx in advance

shabbir 13Nov2007 11:24

Re: HELP...Urgent!!
 
pow(base,j) returns a double but you are using it with an int and so you should cast it

johnd 13Nov2007 19:22

Re: HELP...Urgent!!
 
thnx...i got it to work


All times are GMT +5.5. The time now is 08:49.