title: convert any base to base 10 in C++
body: <p>I have this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  
  int validnumber(int b, char* p);
  unsigned long base2dec(int b,char *p);
  void dec2base (int b,unsigned long x);
  
  char *number;
  
  
  main() {
      int base,temp=0,count;
      unsigned long Decimal_number;
  
      do {
          printf ("Give the base of the number you want to tranform:");
          scanf ("%d", &amp;base);
          if (base&lt;2 || base&gt;16)
              printf("Not acceptable base number, numbers should be in range from 2 to 16\n\n");
      } while (base&lt;2 || base&gt;16);
  
  
      printf ("Give the number you want to tranform:");
      scanf("%s", number);
  
      for (count=0;count&lt;32;count++) {
          number [count]= toupper(number[count]);
      }
  
      temp=validnumber(base, number);
  
      if (temp==0)
          printf ("O arithmpos pou eisagatai periexei MH egkira symbola\n");
      else 
          if (temp==1)
              printf ("O arithmpos pou eisagatai periexei egkira symbola\n");
  
      if (temp==1) {
          Decimal_number =  base2dec( base , number);     
      }
  
  int validnumber(int b, char *p){
  
      int  count, a[32];
  
      for (count=0;count&lt;32;count++)
              a[count]=p[count];
  
      if (b&gt;=2 &amp;&amp; b&lt;=10) {
          for (count=0;count&lt;32;count++) {
              if (a[count]&lt;48 || a[count]&gt;48+b)
                  return 0;
  
              break;
          }
      }
  
      if (b&gt;=11 &amp;&amp; b&lt;=16) {
          for (count=0;count&lt;32;count++) {
              if ((a[count]&gt;=48 &amp;&amp; a[count]&lt;=57) || (a[count]&gt;=65 &amp;&amp; a[count]&lt;=70)) {
                  return 1;
              }
  
          }
      }   
  
  }   
  </code></pre>
  
  <p>From this point the main program must call the function:</p>
  
  <pre><code>unsigned long base2dec (int b, char * p)
  </code></pre>
  
  <p>which accepts as arguments the base b and a pointer p in character table that
  corresponds to the imported string s and returns the number representing the s expressed in the decimal system. 
  Also, it should call the function:</p>
  
  <pre><code>void dec2base (int b, unsigned long x)
  </code></pre>
  
  <p>which accepts as arguments the base b and the value of the number x in the decimal system and displays the base value and the representation of the number x in this base. The main program calls this function for all of the base values from 2 to 16.</p>
  
  <p>Are there any ideas on how to begin? Any guidance will be appreciated.</p>