Skip to main content
2 of 3
added 6 characters in body
C--
  • 306
  • 1
  • 11

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.

C--
  • 306
  • 1
  • 11