title: C reverse function wont work with 32 characters
body: <p>To test my skills, I'm trying to write my own version of a few standard library functions. I wrote a replacement for <code>strlen()</code>, <code>strlength()</code>:</p>
  
  <pre><code>int strlength(const char *c){
      int len = 0;
      while (*c != '\0') {
          c++;
          len++;
      }
      return len;
  }
  </code></pre>
  
  <p>which <em>doesn't</em> include the null-terminator, and I am trying to write a function to reverse a string. This:</p>
  
  <pre><code>char *reverse(const char *s){
      char *str = (char *)malloc(sizeof(char) * strlength(s));
      int i = 0;
      while (i &lt; strlength(s)) {
          str[i] = s[(strlength(s) - 1) - i];
          i++;
      }
      str[strlength(s)] = '\0';
      return str;
  }
  </code></pre>
  
  <p>works for every string except for one with 32 characters (not including null-terminator) like <code>foofoofoofoofoofoofoofoofoofoofo</code>. It hangs in the <code>reverse()</code> functions while-loop. For all other amounts of characters, it works. Why is this happening?</p>