title: find the amount of elements in a char array
body: <p>so im trying to write a program to convert binary to decimal and i have everything correct exect i dont get the correct answer because i dont know how to get the amount of elements that are inputed into the array this is my code</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int a=0;
  
   int main ()
   {
    char  bin[20];
    int i=0, len, r=0, w;
  
    printf("Enter a Binary Number:  ");
    scanf("%s",bin);
    printf("\n");
  
   len = sizeof(bin); /*i know this is my problem how do i get len to be the size 
  of the input of the user for example if the user puts 1010 len should be 4*/
  
    for(i = 0; i &lt; len; i++)
       {
            r = r * 2 + (bin[i] == '1' ? 1 : 0);
         }
  
     printf("Decimal is: %d\n\n",r);
  
  return 0;
   }  
  </code></pre>