I encountered a strange problem earlier. I was working at insertion in B-trees and I wrote a simple display function. I ran it and it didn't show anything in the console even though I inserted some values.
I entered in the debug mode, I followed the flow of the program and the debugger showed me that the tree had values in it. Then I wanted to display only the first node's elements and I had the same problem: an empty console.
I asked my teacher what would be the mistake and he told me to put an endl
after cout
, like this:
cout << node->keys[i] << endl;
It worked!
He told me then that probably I addressed a NULL
pointer in my program and Eclipse doesn't say anything about that but nothing about how endl
could help.
Does anybody know what could be the problem and how that endl
solves it? I'm very very confused.
I didn't understand what flushing the buffer has to do with my display function.