C - Char Array problem

I have to design a program that converts any base from 3 - 36 to binary. The problem I am having is the argument passed into my function keeps telling me that the value is 50 when it is really 2. 2 = 50 0 =48 I cannot find the problem.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
int convert( const char ExValue[], int Base , int * InValue )
{
   int i;
   int count = 0;
   int j = ExValue[0];

   printf( "%i\n" , j );
   for( i = 0 ;; i++ )
   {
      if ( isalnum ( ExValue[i] ))
      {
         count++;
         printf( "%i\n" , ExValue[i] );
      }
      if ( ExValue[i] == '\0' )
      {
         printf( "%i\n" , ExValue[i] );
         break;
      }
   }

   i = 0;
   int Base10Value = 0;
   int Base10Count = count;

   for( count ; count >= 0 ; i++ )
   {
      if ( isalnum ( ExValue[i] ))
      {
         int BaseToPower = 1 ;
         for ( Base10Count ; ( Base10Count - 1 ) > 0  ; Base10Count-- )
         {
            BaseToPower *= Base;
            printf( "%i\n" , BaseToPower );
         }
         printf( "%i\n" , ExValue[i] );
         Base10Value += ( ExValue[i] * BaseToPower);
         count--;
         printf( "%i\n" , Base10Value );
      }
      if ( ExValue[i] == '\0' )
      {
         printf( "%s\n" , "Breaking" );
         break;
      }
   }
         printf( "%i\n" , Base10Value );
}


That is the code I have so far. Many statements are used for error checking and such they can be commented out or deleted. The driver function is pasted below

1
2
3
4
5
6
7
8
int main()
{
   char A[] = "200";
   int * Value;


   convert ( A , 3 , Value );
}


I was also wondering if there is a faster way to convert to binary. I know there are quick ways to do so from Hexadecimal and Octal, but the fastest way ( I thought of off the top of my head ) that works for all bases including ( 13, 14, 15 ) was to convert to a decimal number then to a binary representation of that number.


Thanks for your help in advance.
50 because ASCII value of character 2 is 50
I feel dumb, but thanks a lot for the help.

I am learning C after C++ and I try to take shortcuts. I guess that is a bad idea.
Yes, there are better ways that do not require an intermediary conversion to decimal.
I feel dumb


Don't worry about it dude. We've all done it. :-]
Topic archived. No new replies allowed.