need help... array of linked list
i'm trying to add a node in a linked list..
the problem is like i don't get access to the head of the list (this head declared in a slot of the array) the array consist of a word and a pointer to the position node(linked list)
it gives me segmentation fault..
this is the part to add a new node..
Code:
head = idxADT->words[keyValue].posNumPtr;
if(!strcmp(idxADT->words[keyValue].word," "))
{
strcpy(idxADT->words[keyValue].word, token[j]);
posNode = malloc(sizeof(PositionNode));
if(posNode == NULL)
{
printf("\n Memory Allocated Failure \n");
return FAILURE;
}
posNode->positionNum = j;
/* problem here */
posNode->nextPosition = head->nextPosition;
head->nextPosition = posNode;
}
this is the initialization part
Code:
/* initialise indexADT instance, " " indicates empty slot */
for(i = 0; i < tableSize; i++)
{
strcpy(idxADT->words[i].word," ");
idxADT->words[i].posNumPtr = NULL;
}
can anyone help me??