I am making an array of linked lists, but for some reason its giving me a segmentation error.
Now i know it's not accessing outside the array because i've checked. Yet it only seems to have a problem with that one line noted.
struct NODE
{
char word[WORDSIZE];
struct NODE *next;
};
struct LIST
{
struct NODE listTop;
};
void checkMistakes()
{
char *token;
char word[WORDSIZE];
char lowerWord[WORDSIZE];
int hashValue;
int i=0;
// int found=FALSE;
struct NODE *node;
lineCounter++; //increment the line currently reading
token=strtok(line,delim);
while(token!=NULL)
{
strcpy(word,token);
for(i=0;i<strlen(word) && word[i]!='\0';i++)
{
lowerWord[i]=(char)tolower(word[i]);
}
//puts a null character at the end of the word so array knows where word ends
lowerWord[i]='\0';
hashValue=hash(lowerWord);
printf("%i %s",hashValue,word);
//-----------------------------------------------------------------
//this is the line that keeps having the segmentation error
*node=table[hashValue].listTop;
//-----------------------------------------------------------------
if(table[hashValue].listTop.word[0]!='\0')
{
//search for the word in the list
while(node->word[0]!='\0' && found!=TRUE)
{
if(strcmp(node->word,word)==0)
//then found
found=TRUE;
else
//increment
node = node->next;
}
//printf("%s %s\n",word,lowerWord);
}
// if(found==0)
// {
// enter(word);
// }
token=strtok(NULL,delim);
}
}