Ok, I got most of load working. I figured out the hash function, but now I am a little stuck. If you look at "HELP", you will see that I do not know the code syntax to insert my word into the appropriate hash array. All the examples I find online only deal with 1 linked list, not 50 as I will end up (potentially) having.
#define SIZE 50
typedef struct node
{
char word[LENGTH + 1]
struct node* next
} node;
// Getting my head node
node* head = NULL;
bool load(const char* dictionary)
{
// 26 in alphebet array start like this: A(a-l(12))/A(m-z)(14). No word starts with /'.
// Uneven since beginning of alphebet more common.
node* hashtable[SIZE]
int counter = 0;
while (!feof(dictionary))
{
// I get memory for a new_node(which contains a dictionary word and pointer to next node)
// The fscanf actually gets the word
node* new_node = malloc(sizeof(node));
fscanf(dictionary, "%s", new_node->word);
counter++;
// I get the first char of the word in the node, and set that to key
char* key = new_node->word
//I throw it through my hash function, returning a value from 0 - SIZE
int hash = hash_func(key)
// HELP: Insert my word into hashtable array (by doing hashtable[hash]).
}
return false;
}
// Here I put the key through the hash function (key is word in the dictionary)
// I split hashtable into 52 groups. If the second word of the key is /' or A-L, then it gets the value 0-25 (sorted by 1st letter).
// If the second word is M-Z, then I add 26 to it (so A(M-Z) words are in hash grp 26).
int hash_func (char* key)
{
int output = toupper(key[0]) - 'A';
if (toupper(key[1] >= 'M' && <= 'Z'))
{
output += 26;
}
return output % SIZE;
}