title: C: String manipulation adding more characters without causing a buffer overflow
body: <p>In C I have a path in one of my strings </p>
  
  <pre><code>/home/frankv/
  </code></pre>
  
  <p>I now want to add the name of files that are contained in this folder - e.g. file1.txt file123.txt etc.</p>
  
  <p>Having declared my variable either like this</p>
  
  <pre><code>char pathToFile[strlen("/home/frankv/")+1]
  </code></pre>
  
  <p>or</p>
  
  <pre><code>char *pathToFile = malloc(strlen("/home/frankv/")+1)
  </code></pre>
  
  <p>My problem is that I cannot simply add more characters because it would cause a buffer overflow. Also, what do I do in case I do not know how long the filenames will be?</p>
  
  <p>I've really gotten used to PHP lazy $string1.$string2 .. What is the easiest way to do this in C?</p>