New answers tagged

-1

This is a common error in this pset. Let's look at these statements and think about what could happen: node *head = table[hash_index]; if (head -> next != NULL) Now, let's say that table[hash_index] is null. (This is very likely with a small dictionary or a very large table size.) If it is null, then table[hash_index]->next doesn't exist. ...


2

Initially you have declared node *table[N] as global pointer. As you might have already guessed, all global variables/ pointers are set to default values.(In this case, each pointer is set to NULL). So head = table[hash_index]; // It's still NULL When you do head->next, you're trying to de-reference NULL which results in seg-fault.


1

FYI this is actually re: Lab 5 - Inheritance


2

You don't actually assign to p->parents[1] // TODO: Recursively create blood type histories for parents p->parents[0] = create_family(generations - 1); p->parents[0] = create_family(generations - 1); // Still parents[0], you meant [1] You print parents[1] here print_family(p->parents[1], generation + 1); // seg fault


Top 50 recent answers are included