[英]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. 之前曾有人问过这个问题,但据我
'a.b'
,所有人都是在滥用'a.b'
来获取指针值。 I AM using 'a->b'
but it is still throwing this error. 我正在使用
'a->b'
但仍会引发此错误。 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: .c文件:
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;
}
typedef cel* pile;
and 和
int affiche_pile(pile *p){
This leads to believe that p
is now a pointer to a pointer. 这导致人们相信
p
现在是指向指针的指针。 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
因此,您可以将函数签名更改为
int affiche_pile(pile p)
或typedef cel pile
int affiche_pile(pile p)
pile *p
is double pointer so you change your code something like this: pile *p
是双指针,因此您可以更改代码,如下所示:
affiche_element((*p)->ele);
Change at other places too. 在其他地方也要更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.