RamiB
RamiB

Reputation: 35

[ERROR ]request for member in which is of pointer type maybe you meant to use -> ?) in C BST

i'm trying to delete a node from an bst in line: ((strcmp((*A)->caracterise.nom , Etud.nom) == 0) && (strcmp((*A)->caracterise.prenom , Etud.prenom) == 0) && ((*A)->caracterise.note == Etud.note))

i get [Error] request for member 'caracterise' in '* A', which is of pointer type 'ABR {aka noud*}' (maybe you meant to use '->' ?)

NOTE: etudiant is student; noud is node; caracterise is student information; nom prenom note are name family-name gpa; fG is left bst; fD is right bst; ABR is 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);
        }
    }
}

Upvotes: 1

Views: 7431

Answers (1)

bruno
bruno

Reputation: 32594

A is a ABR**, so a struct noud***, so (*A) is a struct noud** not a struct noud* and (*A)->caracterise is wrong (but (**A)->caracterise legal)

Upvotes: 1

Related Questions