title: Correct way to malloc space for a string and then insert characters into that space?
body: <p>I have two strings, str1 and str2. I want the concatenation of them on a space in the heap. I malloc space for them using:</p>
  
  <pre><code>char *concat = (char*) malloc(strlen(str1) + strlen(str2) + 1);
  </code></pre>
  
  <p>Can I just do:</p>
  
  <pre><code>strcat(concat, str1);
  strcat(concat, str2);
  </code></pre>
  
  <p>And concat will give me the place on the heap with the two strings concatted? I am asking because it seems that strcat would actually add the str1 to the end of the space allocated using malloc. Is this correct? So, then, str1 would appear at position strlen(str1) + strlen(str2) + 1.</p>
  
  <p>The reason that I am asking is that I am using the method above, but I am getting an error in valgrind:
  Conditional jump or move depends on uninitialised value(s)</p>