HELP...Urgent!!

Discussion in 'C' started by johnd, Nov 13, 2007.

  1. johnd

    johnd New Member

    Joined:
    Nov 13, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
     
    Last edited by a moderator: Nov 13, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,341
    Likes Received:
    378
    Trophy Points:
    83
    pow(base,j) returns a double but you are using it with an int and so you should cast it
     
  3. johnd

    johnd New Member

    Joined:
    Nov 13, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    thnx...i got it to work
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice