C:我不知道这是什么意思,而“ while(temp-> next-> next)”]

问题描述 投票:-3回答:1

我有一个类似的结构linkedList

typedef struct linkedList l_List;

struct linkedList{
  hash_It* item;     /*this is hashItem structure include key and value*/
  l_List* next;     /*next list                                       */  
};

而且我的问题是:temp->next->next是什么意思?我怀疑临时数据类型是l_List*而不是l_List**为什么它可以那样用作2级指针?

cre:我在其他来源找到此代码

l_List* temp = list;
    while (temp->next->next) {
        temp = temp->next;
    }
c linked-list structure
1个回答
0
投票

等效于

l_List* find(l_list *temp)
{
    while (temp->next) 
    {
        l_list *temp1 = temp -> next;
        if(temp1 -> next == NULL)
            break; 
        temp = temp->next;
    }
    return  temp;
}

它应该可以帮助您理解它的含义。

    l_list *temp1 = temp -> next -> next;

与]相同>

    l_list *temp1 = temp -> next;
    temp1 = temp1 -> next;
© www.soinside.com 2019 - 2024. All rights reserved.