Commit bd0005cf by Rudolf

Add tree printing support (left->right)

parent 35753548
Showing with 14 additions and 0 deletions
...@@ -45,3 +45,16 @@ void print_char(unsigned char c) ...@@ -45,3 +45,16 @@ void print_char(unsigned char c)
break; break;
} }
} }
void print_tree(struct tree *r,int l)
{
int i;
if(!r) return ;
print_tree(r->right,l+1);
for(i=0;i<l;++i)
printf(" ");
print_char(r->ch);
print_tree(r->left,l+1);
}
...@@ -21,5 +21,6 @@ void __printb(void *value, size_t size); ...@@ -21,5 +21,6 @@ void __printb(void *value, size_t size);
}) })
void print_char(unsigned char c); void print_char(unsigned char c);
void print_tree(struct tree *r,int l);
#endif /* _PRINT_HELPER_H_ */ #endif /* _PRINT_HELPER_H_ */
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