bool HashTable::insert(charconst * const key, const Player& aPlayer)
//calculate the insertion position (the index of the array)
size_t index = calculateIndex(key);
for(int i=0; i < capacity; i++)
if(strcmp(key, table[i]->item.GetName()) == 0)
//create a new node to hold data
node * newNode = new node(aPlayer);
//insert the new node at the beginning of the linked list
newNode->next = table[index];
table[index] = newNode;
The inserting part works just fine, but the checking for duplicates where I compare the two values is crashing my program.
Instead of implementing the search and add into one function, I just made another function that just deals with finding. Then I called the find() in my insert() and if the result was true, don't add, else add.