I'm getting a segmentation fault on my code for Lab 5. Debug50 says line 57 is to blame, and when I look at the info, it looks like parent0 and parent1 are both empty? (If I'm understanding 0x0 right?) Screenshot included:
Am I on the right track seeing that parent0 and parent1 are both empty, so the code is not working? If so, how do I go about fixing this? Actual code included for readability:
person *create_family(int generations)
{
//Allocate memory for new person
person *p = malloc(sizeof(person));
// If there are still generations left to create
if (generations > 1)
{
// Create two new parents for current person by recursively calling create_family
person *parent0 = create_family(generations - 1);
person *parent1 = create_family(generations - 1);
// TODO: Set parent pointers for current person
p->parents[0] = parent0;
p->parents[1] = parent1;
// TODO: Randomly assign current person's alleles based on the alleles of their parents
p->alleles[0] = parent0->alleles[rand() % 2]; //line 57
p->alleles[1] = parent1->alleles[rand() % 2];
}