初始化AVL树时出现分段错误[关闭]

问题描述 投票:0回答:0

我正在尝试初始化一个 AVL 树。出于某种原因,它说我有一个分段错误。

这是树中的信息类型:

typedef struct patientType
{
    int id;
    string name;
    dateptr birthDate;
    appointmentLLL_manager appointment_manager;
} patient, *patientPtr;

这是树:

typedef struct AVLTree
{
    patientPtr info;    //pointer in patient
    short leftH;
    short rightH;
    struct AVLTree* right;
    struct AVLTree* left;
}patientAVLTree, *patientAVLTreePTR, **patientAVLTree_manager;

这是产生问题的初始化:

//initialize
void AVLTree_MakeTree_patient(patientAVLTree_manager root)
{
    patientAVLTreePTR newTree;   //pointer to AVLTree that I will put in the root
    (newTree) = (patientAVLTreePTR)malloc(sizeof(patientAVLTree));
    (newTree)->leftH = 0;
    (newTree)->rightH = 0;
    (newTree)->left = NULL;
    (newTree)->right = NULL;
       
    *root = newTree;    //here the error comes
}
c pointers initialization avl-tree
© www.soinside.com 2019 - 2024. All rights reserved.