title: Reversing a string in C
body: <p>I have developed a reverse-string program. I am wondering if there is a better way to do this, and if my code has any potential problems. I am looking to practice some advanced features of C. </p>
  
  <pre><code>char* reverse_string(char *str)
  {
      char temp;
      size_t len = strlen(str) - 1;
      size_t i;
      size_t k = len;
  
      for(i = 0; i &lt; len; i++)
      {
          temp = str[k];
          str[k] = str[i];
          str[i] = temp;
          k--;
  
          /* As 2 characters are changing place for each cycle of the loop
             only traverse half the array of characters */
          if(k == (len / 2))
          {
              break;
          }
      }
  }
  </code></pre>