Trie implementation runtime error <p>I'm trying to implement a Trie in C++ but I'm getting runtime error... </p> <p>Here is my code:</p> <pre><code>#include &lt;bits/stdc++.h&gt; using namespace std; struct trie{ bool word = false; trie* adj [26]; trie(){} void add(char* s){ trie* t = this; while(s){ if(t-&gt;adj[s[0] - 'a'] == NULL){ trie nova = create(s); t-&gt;adj[s[0] - 'a'] = &amp;nova; return; } else{ t = t-&gt;adj[s[0] - 'a']; } s++; } } trie create(char* s){ trie t; trie* point = &amp;t; while(s){ point-&gt;adj[s[0] - 'a'] = new trie(); point = point-&gt;adj[s[0] - 'a']; s++; } point-&gt;word = true; return t; } void seek(){ trie* t = this; run(t, ""); } void run(trie* t, string s){ if(t-&gt;word){ cout&lt;&lt;s&lt;&lt;"\n"; } for(int i = 0; i &lt; 26; i++){ if(t-&gt;adj[i] != NULL){ run(t-&gt;adj[i], s + char('a' + i)); } } } }; int main(){ trie t; t.add("ball"); t.add("balloon"); t.add("cluster"); t.seek(); } </code></pre> <p>It works like that:</p> <ul> <li><p>suppose I'm adding a word;</p></li> <li><p>if the letter of the word isn't in the trie </p> <pre><code> if(t-&gt;adj[s[0] - 'a'] == NULL) </code></pre> <ul> <li>make new trie with void create and set t->adj[s[0] - 'a'] to that new trie</li> </ul></li> <li><p>else just go to the next letter and repeat the proccess</p> <pre><code> t = t-&gt;adj[s[0] - 'a']; </code></pre></li> </ul> <p>What am I doing wrong? I'm <em>new</em> at using pointers and I think I must have used one (or more) of them mistakenly... What is it wrong?</p>