在这行代码中尝试访问不是结构或联合的“previous”时出现错误错误:*head->previous = newHead
我不太确定为什么......非常感谢任何帮助。
`
struct ListNode
{
int value;
struct ListNode* next;
struct ListNode* previous;
};
void insertAtHead(struct ListNode** head,int val)
{
struct ListNode* newHead = malloc(sizeof(struct ListNode));
newHead->value = val;
newHead->next = NULL;
newHead->previous = NULL;
if(*head == NULL)
*head = newHead;
else
{
newHead->next = *head;
*head->previous = newHead;
*head = newHead;
}
}`