【发布时间】:2013-02-28 21:35:59
【问题描述】:
我想在 c 中获取指向链表中元素的指针。 这是我的代码。我收到错误“返回类型‘bigList’但预期‘struct bigList **’时类型不兼容”。请帮忙。谢谢
/*this is the struct*/
struct bigList
{
char data;
int count;
struct bigList *next;
};
int main(void)
{
struct bigList *pointer = NULL;
*getPointer(&pointer, 'A'); //here how do I store the result to a pointer
}
/*function to return the pointer*/
bigList *getPointer(bigList *head, char value)
{
bigList temp;
temp=*head;
while(temp!=NULL)
{
if(temp->data==value)
break;
temp = temp->next;
}
return *temp; //here I get the error I mentioned
}
【问题讨论】:
-
请至少语法...!如果您甚至没有仔细阅读该 C 教程中有关指针语法的部分,那么您肯定对发生的事情一无所知,这很危险。
-
对不起。我是 c 新手,我忘了添加我使用的 typedef 声明。我想我搞砸了......有很多东西要研究......指针令人困惑......
标签: c struct linked-list