在结构错误中指向取消引用

jel*_*ito 4 c pointers linked-list circular-list dereference

我有一个创建循环列表的功能,我有编译问题,不确定它是否是语法,如果有人可以提供帮助,请欣赏.

    void CreateCircularList(struct node** listRef, struct node** tailRef)

    {    
    Push(&*listRef, "String 1");
    *tailRef=*listRef;
    Push(&*listRef, "String 2");
    Push(&*listRef, "String 3");
    Push(&*listRef, "String 4");

    *(tailRef->next)=*listRef;

    } 
Run Code Online (Sandbox Code Playgroud)

编译器在最后一行标记错误:

"成员引用基类型'结构节点*'不是结构或联合"

有什么想法吗?谢谢

Bas*_*tch 7

你可能想要

  (*tailRef)->next = *listRef;
Run Code Online (Sandbox Code Playgroud)

作为最后一个任务.

你不能写,tailRef->next因为tailRef是一个指针指针.

我还建议只编码 Push(listRef, "Some string");而不是Push(&*listRef, "Some string");出于可读性的原因.