title: Efficiency & Readabilty of a C++ For Loop that Compares two C-style Strings
body: <p>So I've created my own function to compare two C Strings:</p>
  
  <pre><code>bool list::compareString(const char array1[], const char array2[])
  {
      unsigned char count;
      for (count = 0; array1[count] != '\0' &amp;&amp; array2[count] != '\0' &amp;&amp; (array1[count] == array2[count] || array1[count + 32] == array2[count] || array1[count] == array2[count+32]); count++);
      if (array1[count] == '\0' &amp;&amp; array2[count] == '\0')
          return true;
      else
          return false;
  }
  </code></pre>
  
  <p>The parameter of my for loop is very long because it brings count to the end of at least one of the strings, and compares each <code>char</code> in each array in such a way that it their case won't matter (adding 32 to an uppercase <code>char</code> turns that <code>char</code> into its lowercase counterpart).</p>
  
  <p>Now, I'm guessing that this is the most efficient way to go about comparing two C Strings, but that for loop is hard to read because of its length. What I've been told is to use a for loop instead of a while loop whenever possible because a for loop has the starting, ending, and incrementing conditions in its starting parameter, but for this, that seems like it may not apply.</p>
  
  <p>What I'm asking is, how should I format this loop, and is there a more efficient way to do it?</p>