PrevNextAll


Debugging data structures - complex displays

Use a tool such as 'dot'

static void showtreenodes(NODE *cur)
{
 if (!cur) return;
 if (cur->left) {
 	printf("\tN%p -> N%p;\n", cur, cur->left);
	showtree(cur->left);
 }
 if (cur->right) {
 	printf("\tN%p -> N%p;\n", cur, cur->right);
	showtree(cur->right);
 }
}

void showtree(NODE *root)
{
 printf("digraph D {\n");
 showtreenodes(root);
 printf("}\n");
}