I have a function to which I am passing a node tree. The function is supposed to print the node tree in this form:
root
node
node
node
node
node
node
node
node
I cant seem to wrap my head around how to do it. This is what I got so far:
void IterateTree(Node &rNode )
{
printf("\t\n");
std::cout << rNode.Name() << std::endl;
int i = 0;
for (std::list<Node>::iterator it = rNode.childs.begin(); it != rNode.childs.end(); ++it)
{
printf("%d: ", i);
IterateTree(*it);
printf("\b");
i++;
}
}
My Question is: is there a standard way of iterating and printing a node tree with the correct indentation?