I've searched extensively for someone with a similar problem in the forums, but I have yet to find an answer.
I have implemented load() with a trie.
With my implementation of load() in pset5 "speller," I was encountering issues with the way it handled characters from the dictionary file and a conflict with the new line '\n' character. Initially I took the alphabetic characters from fgetc() and subtracted 'a' to reinitialize them to digits 0-25 with the apostrophe character assigned to digit 27 in order to traverse the children of the trie, but I was encountering many issues when running check. I discovered through using debug50 that when loading the dictionary, every time it encountered a '\n' in the dictionary, it changed my variable to it's ASCII value '10' and was traversing the trie through array spot 10 every time the dictionary encountered a '\n' or the letter k.
I ended up using a workaround by increasing the array by 1 space and skipping over the 10th array spot. I ended up noticing a similar issue in my implementation of check() and the terminator '\0' character where my trie path for 'a', assigned to array space 0 was also being traversed by the '\0' character. I had to add another workaround where I added yet another spot to my node array and shifted everything 1 space to the left, leaving open spot 0 and 10.
It compiles, loads checks and returns the correct output, however I believe it is giving me some problems down the road when it comes to memory leaks and I'm sure this is not the way the function was intended to be implemented, nor is it efficient or intuitive.
tl;dr - I've had to create a workaround by increasing the size of my node arrays by 2 and leave open spots 0 and 10 (to avoid conflict with '\0' and '\n' in order for my program to give the desired input. Help me figure out why.
My implementation of load is in this github gist:
And my implementation of check() is here:
Any help with this would be greatly appreciated. Thanks in advance!