【发布时间】:2021-12-27 10:50:22
【问题描述】:
请指出我的代码逻辑中的错误(如果有的话)。它是一个试图在 C 语言双向链表开头插入元素的函数。
struct DLL *insertAthead(struct DLL *head, int newData)
{
struct DLL *p = (struct DLL *)malloc(sizeof(struct DLL *));
p->prev = NULL;
p->next = head;
head->prev = p;
p->data = newData;
head = p;
return head;
}
【问题讨论】:
标签: c dynamic-memory-allocation doubly-linked-list