title: Is there a neat way to do strdup() followed by strcat()?
body: <p>Say I wanted to duplicate a string then concatenate a value to it.</p>
  
  <p>Using stl std::string, it's:</p>
  
  <pre><code>string s = "hello" ;
  string s2 = s + " there" ; // effectively dup/cat
  </code></pre>
  
  <p>in C:</p>
  
  <pre><code>char* s = "hello" ;
  char* s2 = strdup( s ) ; 
  strcat( s2, " there" ) ; // s2 is too short for this operation
  </code></pre>
  
  <p>The only way I know to do this in C is:</p>
  
  <pre><code>char* s = "hello" ;
  char* s2=(char*)malloc( strlen(s) + strlen( " there" ) + 1 ) ; // allocate enough space
  strcpy( s2, s ) ;
  strcat( s2, " there" ) ;
  </code></pre>
  
  <p>Is there a more elegant way to do this in C?</p>