2015-04-03 87 views

回答

0

node = node-> next使节点指向链表中的下一个指针。 由于下一个存储的值是指向列表中下一个元素的指针。 因此,将节点作为node-> next,然后再次调用该函数或在for循环中迭代使您前进。 希望有帮助

0

想象一下用while循环递增一个变量。

int i = 0; 

while (i < 6) { 
    // this loop will run forever without the line below 
    i++; // adds one to i so the loop will not run infinitely 
} 

的概念是与链表一样:

while (node != NULL) { 
    //need to make sure this loop doesn't run forever 
    node = node->next // kind of like incrementing i 
} 

现在while循环运行,直到到达列表的末尾。

相关问题