title: Can you help me find a problem with this basic C code
body: <p>I'm solving some problems from a C programming book to brush up on Strings. I can't figure out why my solution is not working.</p>
  <p>Question asks to write a function named censor that modifies a string by replacing every occurrence of foo by xxx.</p>
  <p>My code:</p>
  <pre><code>int main()
  {
      char msg[] = &quot;I love food, you fool.&quot;;
  
      censor(msg);
  
      puts(msg);
  
      return 0;
  }
  
  void censor(char *str) {
      char *c = str;
      while (c+2 != '\0') {
          if (*c == 'f' &amp;&amp; *(c+1) == 'o' &amp;&amp; *(c+2) == 'o')
              *c = *(c+1) = *(c+2) = 'x';
          c++;
      }
  }
  </code></pre>
  <p>I found that the while loop runs for like 1700 times. I'm pretty sure msg[] will include a null character automatically end of string.</p>