title: Getting Input from a Function - c++
body: <p>I've been having a problem in c++ where I call a function which assigns some values to things, but those assignments are lost after the function has been completed.  Here is my code:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  void Input(string a, string b){
  
      cout &lt;&lt; &quot;Input a: \n&quot;;
      cin &gt;&gt; a;
      cout &lt;&lt; endl;
  
      cout &lt;&lt; &quot;Input b: \n&quot;;
      cin &gt;&gt; b;
      cout &lt;&lt; endl &lt;&lt; &quot;Inputen Strings (still in the called function): \n&quot;;
      cout &lt;&lt; a &lt;&lt; &quot; &quot; &lt;&lt; b &lt;&lt; endl &lt;&lt; endl;
  };
  
  int main(){
      string c = &quot;This didn't&quot;;
      string d = &quot;work&quot;;
  
      Input(c,d);
  
      cout &lt;&lt; &quot;Inputen Strings (now in the main function): \n&quot;;
      cout &lt;&lt; c + &quot; &quot; + d &lt;&lt; endl;
  
      return 0;
  };
  </code></pre>
  <p>So that whenever I run it, (inputting &quot;Hello&quot; and then &quot;World&quot;) the program runs as follows:</p>
  <blockquote>
  <p>Input a:</p>
  <p>Hello</p>
  <p>Input b:</p>
  <p>World</p>
  <p>Inputen Strings (still in the called function):</p>
  <p>Hello World</p>
  <p>Inputen Strings (now in the main function):</p>
  <p>This didn't work</p>
  </blockquote>
  <p>I don't know why it's only temporarily saving the values.  Any help is appreciated!</p>