0

When I try to compare a word with a word in a linked list below at table[index]->word place like follows I'm getting segmentation fault.

if (strcasecmp(word, tmp->word) == 0)
{
    checked = true;
}

Please help me know what can be wrong.

0

Most of the time, when this generates a seg fault, it's because tmp->word doesn't exist, because tmp is null.

Is it possible that a valid node address isn't assigned to tmp? I'm thinking that table[index] might be null. You could insert the following to check:

if(tmp == NULL) printf("TMP is NULL.\n");

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • When I printf tmp->word I'm getting: tmp->word: (null)cat Sep 19 '20 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .