I'm trying to build a simple search function on an array of linked lists that compares values from another array. When I run it six out of ten times I get a segmentation fault. Since this is the first time I've used linked lists in this way, I'm curious why it would work sometimes and not others. Any help would be appreciated.
Code:for (idx = 0; idx < SEARCH_MAX; idx++) { total += count; count = 0; count++; while (nodeArray[address]->value != searchArray[idx] && nodeArray[address]->value != 0) { if (nodeArray[address]->link != NULL) { nodeArray[address] = nodeArray[address]->link; } else { nodeArray[address]++; } count++; } }




Reply With Quote