THOM BOHK
2011-06-15 03:39:25 UTC
I'm trying to debug the insert function in my spellcheck, and I'm
coming across some strange behaviour when I ask for adresses
so I attempt to insert the following words into my trie:
dog
cat
iguana
mouse
parakeet
and I start accessing and printing things on my trie afterwards to see
that everything is where it should be. it appears somehow that a z is
making it into the trie. after inserting dog i go
cout << "d's z POINTER IS " << dic.letters[3]->letters[25] << endl;
and when i run the code it prints 0, for NULL, which it should.
after inserting the rest of the words, i ask again
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
and i get
0x7fffb54cd390
strange.
so back in my code where I look for the pointer to z from the d node,
i just replicate the cout statement 3 times, so it's now
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
and the printed result when i run the code is
0 (the expected NULL, at first)
0x7f7bf8b29301
0x7f7bf8b29301
0x7f7bf8b29301
... but there's no other code running/changed made between the first
cout and the other 3 cout...
does anyone know how this can be happening??? I'm very perplexed. It
looks to me like there's alot of things going on behind the scenes
that I am not understanding...
coming across some strange behaviour when I ask for adresses
so I attempt to insert the following words into my trie:
dog
cat
iguana
mouse
parakeet
and I start accessing and printing things on my trie afterwards to see
that everything is where it should be. it appears somehow that a z is
making it into the trie. after inserting dog i go
cout << "d's z POINTER IS " << dic.letters[3]->letters[25] << endl;
and when i run the code it prints 0, for NULL, which it should.
after inserting the rest of the words, i ask again
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
and i get
0x7fffb54cd390
strange.
so back in my code where I look for the pointer to z from the d node,
i just replicate the cout statement 3 times, so it's now
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
cout << "z POINTER IS " << dic.letters[3]->letters[25] << endl;
and the printed result when i run the code is
0 (the expected NULL, at first)
0x7f7bf8b29301
0x7f7bf8b29301
0x7f7bf8b29301
... but there's no other code running/changed made between the first
cout and the other 3 cout...
does anyone know how this can be happening??? I'm very perplexed. It
looks to me like there's alot of things going on behind the scenes
that I am not understanding...