#include <stdio.h>
#include <stdlib.h>
struct llnode {
int data;
struct llnode *next;
};
void insert (struct llnode **head, int data);
int
main() {
struct llnode *head;
head = NULL;
printf("starting\n");
insert(&head, 4);
return 0;
}
void
insert (**struct llnode **head**, int data) {--> why do we use a pointer to a pointer
printf("insert %0d\n", data);
struct llnode *l = malloc(sizeof(struct llnode));
l->data = data;
l->next = NULL;
if (*head == NULL) {
*head = l;
} else {
struct llnode *tmp = *head;
while (tmp->next != NULL) {
tmp = tmp->next;
}
tmp->next = l;
}
}
1)爲什麼我們要使用指向指針的指針。可以用一個例子來解釋嗎? 2)如何插入雙向鏈表? 請給我解釋一下如何打印爲什麼我們使用指針指針
你讀過這[wiki](http://en.wikipedia.org/wiki/Doubly_linked_list)了嗎? – mvp
我們爲什麼要使用指針? –