<分区>
当我们尝试实现链表时,我无法理解我们创建节点指针而不是节点结构的原因:
typedef struct node {
int val;
struct node * next;
} node_t;
和
node_t * head = NULL;
head = malloc(sizeof(node_t));
if (head == NULL) {
return 1;
}
head->val = 1;
head->next = NULL;
这里,为什么要将head
等节点声明为结构体的指针,而不是直接结构体>