title: extracting a char from a char.Eg 1 from 123
body: <p>In this program convert.c, I am trying to convert a given number of any base to base 10. The command is given as convert   .todecimal is supposed to do that. The code below has errors of course but I am not sure how to make it work. For eg,the number in argv[3]is 123 in base 9. The equation  is supposed to work like this :(1 x 9^2) + (2 x 9^1) + (3 x 9^0) = (102)10.where the variables are (n x argv[3]^i) + (n+1 * argv[3]^i-1)....How do i get a char of 123 when 123 itself a char? Any help is appreciated.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  int todecimal();
  
  main(int argc, char *argv[])
  {
  int s = 0;
  int i = 0;
  int n = 1;
  if (argc &lt; 4) {
     printf("Usage:  convert &lt;basefrom&gt; &lt;baseto&gt; &lt;number&gt;\n");
     }
  printf("to decimal prints %d" todecimal());
  }
  
  int todecimal() {
      if (argv[3] &gt; 0) {
         if ((getchar(argv[3]) != NULL)) {
            i = i + 1;
            }
            while (i &gt;= 0) {
                 s = s + (n * (pow(argv[3],i)));
                 n = n + 1;
                 i = i - 1;
                  }
                  return s;
          }
                  }
  </code></pre>