title: How does this function work? char* getname(); C++
body: <p>I'm starting out on how to code in c++.
  I've been reading c++ primer plus (5th edition) book and came across an example program which I don't fully understand. Basically, the program asks for your last name and gives you the address of where it gets stored:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  using namespace std;
  char* getname();
  int main();
  {
    char* name;
    name = getname();
    cout &lt;&lt; name &lt;&lt; " at " &lt;&lt; (int*)name &lt;&lt; endl;
    delete [] name;
  
    name = getname();
    cout &lt;&lt; name &lt;&lt; " at " &lt;&lt; (int*)name &lt;&lt; endl;
    delete [] name;
  
    return 0;
  }
  
  char* getname()
  {
    char temp[80];
    cout &lt;&lt; "Enter last name: ";
    cin &gt;&gt; temp;
    char* pn = new char [strlen(temp)+1];
    strcpy(pn, temp);
  
    return pn;
  }
  </code></pre>
  
  <p>I don't quite get why char* getname() function needs the dereference operator. I'm having a little bit of trouble understanding this program overall, hehe.
  Sorry if this comes across like a silly question, but I'm quite stuck. That's all. Thank you!..</p>