This line is the problem.
Even if it worked, what if the children had children of their own? To free memory properly, you’d need to add a destructor to the trie struct. (And if you don’t do it properly, you’ve got a memory leak, so it’s at least worth learning how to do it, even if you choose not to here.)