title: C++ char * pointer passing to a function and deleting
body: <p>I have a the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void func(char * aString)
  {
      char * tmpStr= new char[100];
      cin.getline(tmpStr,100);
      delete [] aString;
      aString = tmpStr;
  }
  
  int main()
  {
      char * str= new char[100];
      cin.getline(str,100);
      cout&lt;&lt; str &lt;&lt;endl;
      func(str);
      cout&lt;&lt; str &lt;&lt;endl;
      return 0;
  }
  </code></pre>
  
  <p>Why the second <code>cout</code> does not print the second input string? How can I change this code to work it?</p>