For some reason my algorithm to convert a hexadecimal number into a decimal number doens't work and I cna't figure it out. Any help would be appreciated.

Code:#include<string.h> #include<math.h> #include<stdio.h> //dest is a character array that holds my hexedecimal string int todecimal(char *dest) { int pos, sum, power_of_16; //pos is the current element in the dest array pos=strlen(dest); power_of_16=0; sum=0; do{ --pos; if(dest[pos]<=9) sum+=dest[pos]*pow(16,power_of_16); switch(dest[pos]){ case 'a': sum+=10*pow(16,power_of_16); break; case 'b':sum+=11*pow(16,power_of_16); break; case 'c':sum+=12*pow(16,power_of_16); break; case 'd':sum+=13*pow(16,power_of_16); break; case 'e':sum+=14*pow(16,power_of_16); break; case 'f':sum+=15*pow(16,power_of_16); break; default: /*do nothing*/ break; } power_of_16++; }while(pos!=0); return sum; }