I can't seem to break out of this infinite loop here is my pseudo code:
malloc cursor
malloc new_node
for(length of word)
{
if(letter is uppercase)
{
make letter uppercase
}
}
copy string of of word to new_nod->word
hash it
make cursor = table[hash]
while (cursor is not NULL) //here is where the infinite loop begins
{
if( cursor->word = new_node->word) //this is using strcmp
{
return true
make cursor = cursor->next;
}
}
in my load function I use the following to avoid collisions:
while(end of file not yet reached)
{
get word
hash it
if(table[hash] is not = to NULL)
{
new_node->next = table[hash]
}
table[hash] = new_node;
}
EDIT 0: Following, @Kareem 's advice, I have made one minor change, but I still cannot fix the problem. here is my modified code
malloc cursor
malloc new_node
for(length of word)
{
if(letter is uppercase)
{
make letter uppercase
}
}
copy string of of word to new_nod->word
hash it
make cursor = table[hash]
while (cursor is not NULL) //here is where the infinite loop begins
{
if( cursor->word = new_node->word) //this is using strcmp
{
return true
}
make cursor = cursor->next;
}
EDIT 1: It seems to me that cursor is not changing even though I tell it to equal cursor->next!