Jessica Chambers Jessica Chambers - 6 days ago 8
C Question

C - error: request for member ‘---’ in something not a structure or union

This question has been asked before, but from what I have seen it's all people that are misusing

'a.b'
to get pointer values. I AM using
'a->b'
but it is still throwing this error.
Here's my code, it's meant to be a dynamic stack:

Header file:

typedef struct etCel{
element *ele;
struct cel *suiv;
} cel;

typedef cel* pile;

pile init_pile();
int affiche_pile(pile *p);


.c file:

pile init_pile(pile *p){
return NULL;
}
int affiche_pile(pile *p){
printf("Valeurs de la pile:\n");
while(p!=NULL){
affiche_element(p->ele);
printf("\n");
p=*(p->suiv);
}
return 1;
}

Answer
typedef cel* pile;

and

int affiche_pile(pile *p){

This leads to believe that p is now a pointer to a pointer. Expand the declarations and you get

cel* *p;

So either you change the function signature to int affiche_pile(pile p) or typedef cel pile