Hi, I am not able to destroy a hash table. I have put the destroy function below:

void desTable(ListNode* v[10])
{
    ListNode* temp;
    ListNode* tempNext;
    for (int i = 0; i < 10; i++)
    {
        if (NULL != v[10])
        {
            temp = v[10];
            while (NULL != temp)
            {
                tempNext = temp->next;
                delete temp;
                temp = tempNext;
            }
            v[10] = NULL;
        }
    }
}

Recommended Answers

All 2 Replies

Just from a qucik perusal of your code, it looks to me that instead of iterating through the array by using i as the index, you've hard coded the index as 10, the eleventh element in the array, which is beyond the bounds of the array. Try replacing the 10 with i inside the loop.

temp and tempNext are used only internally this method why do they have pointers ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.