C malloc struct implementation : <p>I am having a problem with the following program. When I try to compile it, it crashes. I guess it's a segmentation fault somewhere in insert function but I just can't figure out where.</p>

<pre><code>char *names[HOW_MANY]= {"Simon", "Suzie", "Alfred", "Chip", "John", "Tim",
          "Harriet"};
int ages[HOW_MANY]= {22, 24, 106, 6, 18, 32, 24};

struct person 
{
  char name[40];
  unsigned int age;
  struct person *next;
};

struct person* insert(struct person *people[], char *name, int age) 
{
  struct person *ptr;
  ptr=(struct person * )malloc(sizeof(struct person));
  if(ptr==NULL)
  {
    printf("error");
    return;
  }
  //ptr=ptr-&gt;next;
  strcpy(ptr-&gt;name,name);
  ptr-&gt;age = age;
  ptr-&gt;next=NULL;

}

int main() 
{
  struct person *people[HOW_MANY];
  for (int i =0; i&lt;HOW_MANY;i++) 
      insert (people, names[i], ages[i]);

  for(int i=0;i&lt;HOW_MANY;i++)
    printf("%s %d\n", people[i]-&gt;name, people[i]-&gt;age);
  return 0;
}
</code></pre>
