title: How to convert binary string to an unsigned int?
body: <p>I'm trying to convert a binary string to an unsigned int but I still can't get the way to make it possible, here is my code which probably won't make a lot of sense:</p>
  
  <pre><code>unsigned int binary_to_uint(const char *b)
  {
      unsigned int k = 2;
      unsigned int i;
      unsigned int c;
      unsigned int len;
      if (b == NULL)
          return (0);
      len = strlen(b);
      for (c = len; c &gt; 0; c--)
      {
          if (b[c] != 48 || b[c] != 49)
              return (0);
          if (b[c] == '1')
          {
              i += atoi(b) * k;
          }
          k *= 2;
      }
      return (i);
  }
  </code></pre>