I am trying to retrieve a linked list from a hash table.
My code right now only grabs the first node of the linked list. How do I get the whole list? And what the return type should be?
So I have a struct representing an entry:
typedef struct Entry {
char *word;
int len;
struct Entry *next;
} Entry;
And I make a array of those entries as my table (And I do malloc spaces for each element of the table in my program):
struct Entry *table[TABLE_SIZE] = { NULL }; // an array of elements
This is my get function. It receives the hash value, then returns the linked list at that location. I believe I need a loop here but I don't really know how to implement it.
struct Entry* getList(int h) {
// Return linked list
return table[h];
}