title: How can I use stringstream as a parameter for a c++ function?
body: <p>I was looking for solutions to appending strings with other primitives and found that stringstream was the easiest solution.  However, I wanted to streamline the process so I wanted to make a function to ease its use.  In case you are proposing alternate methods for concatenation, i need the final result to be char*.  I used a loop (i) with:</p>
  
  <pre><code>std::stringstream ss;
  ss &lt;&lt; "test" &lt;&lt; i;      
  char* name = new char[ss.str().size() + 1];//allocate
  strcpy(name, ss.str().c_str());//copy and put (char*)c_str in name
  </code></pre>
  
  <p>So the output is something link test1test2test3...  This was the most reasonable solution I could muster.  I was trying to put it into a function for ease of use, but am running into problems. I wanted to do something like:  </p>
  
  <pre><code>char* string_to_pointer( char* dest, std::stringstream* _ss ) {
     char* result = new char[_ss-&gt;str().size() + 1];
     strcpy(result, _ss-&gt;str().c_str());
     return result;
  }
  </code></pre>
  
  <p>I could then do something like:</p>
  
  <pre><code>std::stringstream ss;
  ss &lt;&lt; "test" &lt;&lt; i;      
  char* name = string_to_pointer( name, &amp;ss );
  </code></pre>
  
  <p>I'm pretty new to c++ and this seems like the correct use syntactically, but I am running into runtime issues and would welcome solutions on how to get this in an easy to use function without resulting to Boost.</p>