title: C appending char to char*
body: <p>So I'm trying to append a <code>char</code> to a <code>char*</code>.</p>
  
  <p>For example I have <code>char *word = " ";</code>
  I also have <code>char ch = 'x';</code></p>
  
  <p>I do <code>append(word, ch);</code> Using this method..</p>
  
  <pre><code>void append(char* s, char c)
  {
  
      int len = strlen(s);
      s[len] = c;
      s[len+1] = '\0';
  }
  </code></pre>
  
  <p>It gives me a segmentation fault, and I understand why I suppose. Because <code>s[len]</code> is out of bounds. How do I make it so it works? I need to clear the <code>char*</code> a lot as well, if I were to use something like char word[500]; How would I clear that once it has some characters appended to it? Would the <code>strlen</code> of it always be <code>500</code>? Thanks in advance.</p>