一、tree.h
#pragma once
#include<stdio.h>
#include<stdlib.h>
typedef struct binary_sort_tree {
int* data;
void* left;
void* right;
char ptr;
}bst;
#define BST_SIZE sizeof(bst)
bst* tree_root;//这里如果赋初始值,就是定义了,声明可以多次,但是定义只能一次。两个.c文件重复引入头文件,就会有两次定义,会出错
//int bst_num;
void bst_insertNode(bst* node, int sdata);
void bst_free_space(bst* node);
void bst_print_tree(bst* node);
void init_bst_tree();
int bst_deleteNode(bst* node, int sdata);
int bst_delete(bst* node);
二、binary_sort_tree.c
#define _CRT_SECURE_NO_WARNINGS
#include "tree.h"
int bst_num = 0;
//初始化二叉排序树
void init_bst_tree() {
int temp = 0;
printf("请输入节点的个数:\n");
scanf("%d", &bst_num);
printf("请依次输入节点的值:\n");
tree_root = (bst*)malloc(BST_SIZE);
tree_root->data = NULL;
tree_root->left = NULL;
tree_root->right = NULL;
tree_root->ptr = 'p';