title: nested structs - input
body: <p>i need to input name to a variable (first name*) in a struct
  with a malloc
  i don't understand why to program is fail to run.
  im inserting the name (for example David)
  and its should gets the name and put it in temp array
  and then to resize the pointer first_name*
  and copy the string temp to first_name*</p>
  
  <p>someone can help me understand why its doesn't work?</p>
  
  <p>look for the function "ReadPerson".</p>
  
  <pre><code>typedef struct{
      int day, month, year;
  }  Date;
  
  typedef struct{
      char *first_name, *last_name;
      int id;
      Date birthday;
  }  Person;
  
  void ReadDate(Date *a)
  {
      printf("insert day, month, year\n");
      scanf("%d%d%d", &amp;a-&gt;day, &amp;a-&gt;month,&amp;a-&gt;year);
  }
  
  void ReadPerson(Person *b)
  {
      char temp_first_name[21];
      char temp_last_name[21];
  
      printf("insert first name:\n");
      gets(temp_first_name);
      b-&gt;first_name = (char*)malloc(strlen(temp_first_name)+1);
      strcpy(b-&gt;first_name,temp_first_name);
      //need to check malloc (later)
  
      printf("insert last name:\n");
      gets(temp_last_name);
      b-&gt;last_name = (char*)malloc(strlen(temp_last_name)+1);
      strcpy(b-&gt;last_name, temp_last_name);
      //need to check malloc (later)
  
      printf("insert id\n");
      scanf("%d",&amp;b-&gt;id);
  
      printf("insert person's birthday:\n");
      ReadDate(b);
  }
  </code></pre>
  
  <p>Thanks.</p>