Convert a binary number to a decimal in C

#include< stdio.h>
#include< stdlib.h>
#include< math.h>

unsigned long int puiss(unsigned long int x, int n)
{
  if(n == 0)
    return 1;
  if(n == 1)
    return x;
  unsigned long int x2 = powers(x,n/2);
  if(n%2 == 0)
    return x2*x2;
  return x2 * x2 * x;
}
int char_to_int(char d)
{
  char str[2];
  str[0] = d;
  str[1] = '\0';
  return (int) strtol(str, NULL, 10);
}

unsigned int convertirEnBase10(int binary)
{
          char snum[20];
          // convert to String
          itoa(binary,snum,10);
          // how many characters?
          int nc = log10((int)binary)+1;
          int decimal = 0;
          for(int i = nc-1  ; i >= 0; i--)
          {
            decimal += char_to_int(snum[i]) * puiss( 2, (nc-1)-i);
         }
          return decimal;
}
         
int main()
{
      binary int;
      while(true)
      {
          printf("Enter a binary number ");
          scanf("%d",& binary);
          printf ("%ld in base 2 = %ld in base 10\n",binary, convertInBase10 (binary);
      }
      return 0;
}