c - [错误]请求其中是指针类型的成员,也许您打算在 C BST 中使用 -> ?)

标签 c pointers binary-search-tree

我正在尝试从 bst 中删除一个节点 行: ((strcmp((*A)->caracterise.nom , Etud.nom) == 0) && (strcmp((*A)->caracterise.prenom , Etud.prenom) == 0) && (( *A)->caracterise.note == Etud.note))

我收到对“* A”中成员“characterise”的[错误]请求,该成员的指针类型为“ABR {aka noud*}”(也许您想使用“->”?)

注意:etudiant 是学生; noud 是节点; caracterise 是学生信息; nom prenom 注意是姓名-姓氏 GPA; fG 左为 bst; fD 是正确的 bst; ABR 是 BST

struct etudiant
{
char nom[13]; 
char prenom[13];
float note;
};

struct noud
{
etudiant caracterise;
struct noud*fG;
struct noud*fD;
};

typedef struct noud*ABR;

void supprimer(ABR** A, etudiant Etud){
if ((strcmp((*A)->caracterise.nom , Etud.nom) == 0) && (strcmp((*A)->caracterise.prenom , Etud.prenom) == 0) && ((*A)->caracterise.note == Etud.note)) {
    //if ((test(*A, Etud) == 0)&& (*A->caracterise.note == Etud.note)){
    ABR* a;
    a = (ABR*)malloc (sizeof(noud));
    a = (*A)->fD ;
    ABR* b;
    b = (ABR*)malloc (sizeof(noud));
    if ( a != NULL ) {
        if ( a->fG != NULL ) {
            while ( a->fG->fG != NULL ) {
                a = a->fG ;
            }
            b = a->fG ;
            b->fG = (*A)->fG ;
            a->fG = b->fD ;
            b->fD = (*A)->fD;
            a = (*A);
            (*A) = b ;
            free(a);
        }else{
            a->fG = (*A)->fG ;
            free(*A);
            (*A) = a ;
        }
    }else{
        a = *A ;
        (*A) = (*A)->fG ;
        free(a);
    }
}else{
    if ( v.priorite > (*A)->val.priorite ) {
        supprimer(&(*A)->fD, Etud);
    }else{
        supprimer(&(*A)->fG, Etud);
        }
    }
}

最佳答案

AABR**,因此是 struct noud***,因此 (*A) 是一个 struct noud** 而不是 struct noud* 并且 (*A)->caracterise 是错误的(但是 (* *A)->特征化合法)

关于c - [错误]请求其中是指针类型的成员,也许您打算在 C BST 中使用 -> ?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54143304/

相关文章:

c - 系统调用不同的硬件架构?

c - 在控制台模式下更改/过滤 GDB 输出

C++ 堆栈内存未被释放

c - 在对指针到指针数组调用 realloc 以缩小其大小之前是否有必要释放子指针?

c++ - 在 C++ 函数中,指针与索引数组

algorithm - 创建平衡二叉搜索树的输入

c - 循环展开优化,这是如何工作的

c++ - 使用 FFmpeg Libav 从网络摄像头获取视频

c - 如何按名称(字符串)排序和搜索 BST?

c++ - 如何在 C++ 中删除 BST?