我有一个二进制搜索树,我可以将用户输入放入其中并将数组放入其中 . 我的问题是当我调用我的删除节点功能时,没有任何内容被删除 . 我在下面提供的是我的代码 . 我删除了所有不必要的代码剩下的就是一个工作输入函数和一个破坏删除函数 . 我把删除功能和其他功能放在main之前,这样更容易看到 . 输入低于主要

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h> 
#include <string.h>
#include <malloc.h>
#define MAX 10

char* nameArray[] = { "Bob", "Troy", "Luna", "Glen", "Tat",
        "Hut", "Tree", "Troy", "Steve", "Tucker", NULL };
char* number[] = { "610-11-1212", "508-123-1000", "617-555-1212",
        "818-919-8100", "710-777-1170", "310-333-1300", "510-555-1001","333-310-3201", "445-440-0044", "220-210-2210", NULL };
char* ID[] = { "610-11-1212", "508-123-1000", "617-555-1212",
        "818-919-8100", "710-777-1170", "310-333-1300", "510-555-1001","333-310-3201", "445-440-0044", "220-210-2210", NULL };
char* hours[] = { "610-11-1212", "508-123-1000", "617-555-1212",
        "818-919-8100", "710-777-1170", "310-333-1300", "510-555-1001","333-310-3201", "445-440-0044", "220-210-2210", NULL };
char* pay[] = { "610-11-1212", "508-123-1000", "617-555-1212",
        "818-919-8100", "710-777-1170", "310-333-1300", "510-555-1001","333-310-3201", "445-440-0044", "220-210-2210", NULL };
int flag;
typedef struct node
{

    char* name;
    char* phoneNum;
    char* ID;
    char* hours;
    char* pay;
    struct node * left;
    struct node * right;
} node_t;



struct node * minValueNode(struct node* node)
{
    struct node* current = node;

    while (current->left != NULL)
        current = current->left;

    return current;
}
struct node* deleteNode(struct node* root, char* name)
{

    if (root == NULL) return root;

    if (name < root->name)
        root->left = deleteNode(root->left, name);

    else if (name > root->name)
        root->right = deleteNode(root->right, name);


    else
    {

        if (root->left == NULL)
        {
            struct node *temp = root->right;
            free(root);
            return temp;
        }
        else if (root->right == NULL)
        {
            struct node *temp = root->left;
            free(root);
            return temp;
        }

        struct node* temp = minValueNode(root->right);

        root->name = temp->name;

        root->right = deleteNode(root->right, temp->name);
    }
    return root;
}

int main()
{

    node_t * test_list = malloc(sizeof(node_t));

    test_list->name = "";
    test_list->phoneNum = "";
    test_list->ID = "";
    test_list->hours = "";
    test_list->pay = "";
    test_list->left = NULL;
    test_list->right = NULL;


    for (int i = 0; i < MAX; i++) {
        insert(test_list, nameArray[i], number[i], ID[i], hours[i], pay[i]);
    }
    print_tree_inorder(test_list);

    int choice;
    bool x = true;
    while (x != false) {
        printf("Please chose one of the following options: \n1: Print list\n5:Delete someone\n9:END\n");
        scanf("%d", &choice);

        switch (choice)
        {
        case 1:
            print_tree_inorder(test_list);
            break;


        case 5:
            ;//this has to be here so I can scan. Not errors
            char* deleteName = malloc(51);
            printf("Please enter in Name to delete entry: ");
            scanf("%50s", deleteName);
            deleteNode(test_list, deleteName);
            printf("\n\nNEW LIST\n\n");
            print_tree_inorder(test_list);
            break;

        case 9:
            x = false;
            break;

        default:
            printf("NOT FOUND");
            break;

        }
    }

    return 0;   
 }

这是输出

Bob  610-11-1212                                                                                                                                                                    
 Glen  818-919-8100                                                                                                                                                                  
 Hut  310-333-1300                                                                                                                                                                   
 Luna  617-555-1212                                                                                                                                                                  
 Steve  445-440-0044                                                                                                                                                                 
 Tat  710-777-1170                                                                                                                                                                   
 Tree  510-555-1001                                                                                                                                                                  
 Troy  508-123-1000                                                                                                                                                                  
 Troy  333-310-3201                                                                                                                                                                  
 Tucker  220-210-2210                                                                                                                                                                
Please chose one of the following options:                                                                                                                                           
1: Print list                                                                                                                                                                        
4:Input New Person                                                                                                                                                                   
5:Delete someone                                                                                                                                                                     
9:END                                                                                                                                                                                
5                                                                                                                                                                                    
Please enter in Name to delete entry: Tucker                                                                                                                                         


NEW LIST                                                                                                                                                                             


 Bob  610-11-1212                                                                                                                                                                    
 Glen  818-919-8100                                                                                                                                                                  
 Hut  310-333-1300
 Luna  617-555-1212                                                                                                                                                                  
 Steve  445-440-0044                                                                                                                                                                 
 Tat  710-777-1170                                                                                                                                                                   
 Tree  510-555-1001                                                                                                                                                                  
 Troy  508-123-1000                                                                                                                                                                  
 Troy  333-310-3201                                                                                                                                                                  
 Tucker  220-210-2210                                                                                                                                                                
Please chose one of the following options:                                                                                                                                           
1: Print list                                                                                                                                                                        
4:Input New Person                                                                                                                                                                   
5:Delete someone                                                                                                                                                                     
9:END                                                                                                                                                                                
1                                                                                                                                                                                    

 Bob  610-11-1212                                                                                                                                                                    
 Glen  818-919-8100                                                                                                                                                                  
 Hut  310-333-1300                                                                                                                                                                   
 Luna  617-555-1212                                                                                                                                                                  
 Steve  445-440-0044                                                                                                                                                                 
 Tat  710-777-1170                                                                                                                                                                   
 Tree  510-555-1001                                                                                                                                                                  
 Troy  508-123-1000                                                                                                                                                                  
 Troy  333-310-3201                                                                                                                                                                  
 Tucker  220-210-2210                                                                                                                                                                
Please chose one of the following options:                                                                                                                                           
1: Print list                                                                                                                                                                        
4:Input New Person                                                                                                                                                                   
5:Delete someone                                                                                                                                                                     
9:END

我在这里使用删除功能做错了什么?对不起,如果错误很明显 . 我是C语法的新手,但仍然渴望学习如何做到这一点!同时忽略进入ID数小时和付费的数据的坏数据,虽然它与数字相同,但它不应该有所作为 .