title: Why is this C++ string length calculation function faster than this other one?
body: <p>Our lecturer has explained that this piece of function which calculates the length of a character string...</p>
  
  <pre><code>int strlen_1(const char *str) {
      const char *temp = str;
      while(*temp != '\0') {
          temp++;
      }
      return temp - str;
  }
  </code></pre>
  
  <p>... will calculate it faster than this one...</p>
  
  <pre><code>int strlen_03(const char *str) {
      int i;
      for (i = 0; *(str+i) != '\0'; i++);
      return i;
  </code></pre>
  
  <p>I think he said that it was related to arithmetic calculations, something like in the first one any arithmetic calculus is done, but I cannot understand that, I see them both in the same level. Could you please explain me the reason in other words? </p>
  
  <p>PS. I do understand pointers and I can understand what is going on, it is like stepping through the elements of the array stored into the "RAM cells" by one unit.</p>
  
  <p>Thanks in advance.</p>