title: C replace special character
body: <p>I would like to replace the <code>'</code> character with <code>\'</code> I use the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main() {
      int i, j = 0;
      char str[] = "HELLO'All";
      char pch[128] = { 0 };
  
      for (i = 0; i &lt; strlen(str); i++) {
          if (str[i] == '\'') {
              pch[j] = '\\';
              printf(" pch[%d] = *%c* \n", j, pch[j]);
              pch[++j] = str[i];
              continue;          
          }
          pch[j++] = str[i];
      }
      printf("pch = *%s* \n", pch);
      return 0;
  } 
  </code></pre>
  
  <p>I get the result: <code>pch = *HELLO\All*</code><br>
  Expected result: <code>pch = *HELLO\'All*</code><br>
  What is missing in my code?</p>