title: Undefined behavior when converting char to std::string c++
body: <p>My program takes in a vector <code>std::vector&lt;std::string&gt; vector</code> and a character <code>char separator</code> and returns a string with all of the strings added together between the separator character. The concept is: <code>vector[0] + separator + vector[1] + separator</code></p>
  <p><strong>The Code</strong></p>
  <pre><code>std::string VectorToString(std::vector&lt;std::string&gt; vector, char separator)
  {
      std::string output;
      for(std::string segment : vector)
      {  
          std::string separator_string(&amp;separator);
          output += segment + separator_string;
      }
      return output;
  }
  
  int main()
  {
      std::vector&lt;std::string&gt; vector = {&quot;Hello&quot;,  &quot;my&quot;,  &quot;beautiful&quot;, &quot;people&quot;};
      std::cout &lt;&lt; VectorToString(vector, ' ');
  }
  </code></pre>
  <p>My expected output is <code>Hello my beautiful people </code>
  However the output is:</p>
  <p><code>Hello �����my �����beautiful �����people �����</code></p>
  <p>What I have found is that something is wrong with the character, specifically its pointer: <code>std::cout &lt;&lt; &amp;separator;</code> -&gt; <code>�ƚ��</code>. However if I do like this: <code>std::cout &lt;&lt; (void*) &amp;separator;</code> -&gt; <code>0x7ffee16d35f7</code>. Though I don't really know what <code>(void*)</code> does.</p>
  <p><strong>Question:</strong></p>
  <p>1.What is happening?</p>
  <p>2.Why is it happening?</p>
  <p>3.How do I fix it?</p>
  <p>4.How do I prevent it from happening in future projekts?</p>