Database/db.c
void db_print_recurs(node_t *node, int lvl, FILE *out) {
    // print spaces to differentiate levels
    print_spaces(lvl, out);

    // print out the current node
    if (node == NULL) {
        fprintf(out, "(null)\n");
        return;
    }

    if (node == &head) {
        fprintf(out, "(root)\n");
    } else {
        fprintf(out, "%s %s\n", node->name, node->value);
    }

    db_print_recurs(node->lchild, lvl + 1, out);
    db_print_recurs(node->rchild, lvl + 1, out);
}
/* Recursively traverses the database tree and prints nodes
 * pre-order. */
Recursively traverses the database tree and prints nodes
pre-order.
Recursively traverses the database tree and prints nodes pre - order .
void db_print_recurs(node_t *node, int lvl, FILE *out) {
    print_spaces(lvl, out);
    if (node == NULL) {
        fprintf(out, "(null)\n");
        return;
    }
    if (node == &head) {
        fprintf(out, "(root)\n");
    } else {
        fprintf(out, "%s %s\n", node->name, node->value);
    }
    db_print_recurs(node->lchild, lvl + 1, out);
    db_print_recurs(node->rchild, lvl + 1, out);
}
void db_print_recurs ( node_t * node , int lvl , FILE * out ) { print_spaces ( lvl , out ) ; if ( node == NULL ) { fprintf ( out , " \n " ) ; return ; } if ( node == & head ) { fprintf ( out , " \n " ) ; } else { fprintf ( out , " \n " , node -> name , node -> value ) ; } db_print_recurs ( node -> lchild , lvl + 1 , out ) ; db_print_recurs ( node -> rchild , lvl + 1 , out ) ; }
Recursively traverses the database tree and prints nodes
 pre-order.
Recursively traverses the database tree and prints nodes pre - order .
// print spaces to differentiate levels // print out the current node