Commit 3e5150f8 by Rudolf

Improve print tree graph

parent 54078c4a
Showing with 2 additions and 1 deletions
...@@ -54,6 +54,7 @@ void print_char(unsigned char c) ...@@ -54,6 +54,7 @@ void print_char(unsigned char c)
void print_tree(struct tree *parent) void print_tree(struct tree *parent)
{ {
int level = 1; int level = 1;
printf("Showing tree\n");
while (parent->left != NULL ) { while (parent->left != NULL ) {
if (parent->right) { if (parent->right) {
for (int i = 0; i < level; i++) for (int i = 0; i < level; i++)
...@@ -66,7 +67,7 @@ void print_tree(struct tree *parent) ...@@ -66,7 +67,7 @@ void print_tree(struct tree *parent)
} }
printf("o\n"); printf("o\n");
if (parent->left && parent->left->ch != 0) { if (parent->left && !parent->left->left) {
for (int i = 0; i < level; i++) for (int i = 0; i < level; i++)
printf(" "); printf(" ");
print_char(parent->left->ch); print_char(parent->left->ch);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment