title: Assigning a value to char* in a struct
body: <p>I have problem with my code i cant assign a string value into char* in a struct. Can someone tell me what is wrong with my code and why?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  typedef struct{
  char* name;
  char* city;
  int age;
  } person;
  void main()
  {
  person * user;
  user = (person*)malloc(sizeof(person*));
  
  cout &lt;&lt; "Please fill in the user info.." &lt;&lt; endl &lt;&lt; "Name: ";
  cin &gt;&gt; user-&gt;name;
  cout &lt;&lt; "Age: ";
  cin &gt;&gt; user-&gt;age;
  cout &lt;&lt; "City";
  cin &gt;&gt; user-&gt;city;
  
  cout &lt;&lt; "The user info is:" &lt;&lt; endl &lt;&lt; "Name: " &lt;&lt; user-&gt;name &lt;&lt; endl &lt;&lt; "Age: " &lt;&lt; user-&gt;age &lt;&lt; endl &lt;&lt; "City: " &lt;&lt; user-&gt;city &lt;&lt; endl;
  system("pause");
  }
  </code></pre>
  
  <p>Thank you very much.</p>