weird cout output

Sep 23, 2011 at 2:17pm
hi,
i get this really weird output when running this program, does anyone know why???

this is the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void Tree::printTreeList()
{
	unsigned int i;
	cout << "\n\n\n LISTING \n";
	cout << treeVector.size();
	for(i=0 ; i < treeVector.size() ; i++)
   {
        TreeElement *treeElement = treeVector[i];
        cout << treeElement->getName();
        cout << "\n";
        cout << "NEXT \n";
        //cout << treeVector[i]->getName();
   }

}


and this is the output
 LISTING 
28`�;`�;h�;h�;p�;p�;x�;x�;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;Ȥ;Ȥ;Ф;Ф;ؤ;ؤ;��;��;��;��;��;��;��;��;�;���;�;�;<�;<�; �; �;(�;(�;0�;0�;8�;8�;@�;@�;H�;H�;P�;P�;X�;X�;`�;`�;h�;h�;p�;p�;x�;x�;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;ȥ;ȥ;Х;Х;إ;إ;��;��;��;��;��;��;��;��;�;���;�;�;<�;<�; �; �;(�;(�;0�;0�;8�;8�;@�;@�;H�;H�;P�;P�;X�;X�;`�;`�;h�;h�;p�;p�;x�;x�;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;Ȧ;Ȧ;Ц;Ц;ئ;ئ;��;��;��;��;��;��;��;��;�;���;�;�;<�;<�; �; �;(�;(�;0�;0�;8�;8�;@�;@�;H�;H�;P�;P�;X�;X�;`�;`�;h�;h�;p�;p�;x�;x�;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;��;ȧ;ȧ;Ч;Ч;ا;ا;��;��;@��;s,0t,�t,�{;@��������
���@����
            	�;


normaly it should output a list of files/folders in my root dir
Sep 23, 2011 at 3:30pm
Think you have to dereference the treeElement before you can call its class members.

Better yet, don't bother with pointers in this kind of exercise. No added value and it makes debugging impossible.
Topic archived. No new replies allowed.