Hot answers tagged

9

It's actually a simple fix. Since it's something that you would either know or not know, here it is. You declare the pointer variable as a global outside of a function, but you malloc space for it inside of main or another function. It's the = malloc(...) part that's killing you here. You can't do that outside of main or another function. If this answers ...


2

The trie starts at one root node. This node will always have the is_word bool as false because the root node doesn't actually represent a letter. For a one letter word, say a, you would first move one level into the tree, as in root->children[0] before setting that node's is_word to true. (a two letter word, like ad, would traverse the path of root->...


Only top voted, non community-wiki answers of a minimum length are eligible