浙大翁恺C语言链表的代码报错为什么

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
 #ifndef _NODE_H_
#define _NODE_H_
typedef struct _node{
    int value;
    struct _node *next;
} Node;

#endif
typedef struct _list{
    Node* head;
}List;
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    List list;
    Node *head=NULL;
    int number;
    list.head=NULL;
    do{
        scanf("%d",&number);
        if(number!=-1){
            add(&list,number);
        }
    }while(number!=-1);
    
    return 0;
}
void add(List *plist,int number){
    
          Node *p=(Node*)malloc(sizeof(Node));
          p->value=number;
          p->next=NULL;
          Node *last;
          last=*plist->head;
          if(last){
            while(last->next){
           last=last->next;
       }
          last->next=p;
    }else{
        plist->head=p;
    }
}

运行结果及报错内容

 incompatible types when assigning to type 'struct Node* ' from type 'Node'

你题目的解答代码如下:

#ifndef _NODE_H_
#define _NODE_H_
typedef struct _node{
    int value;
    struct _node *next;
} Node;

#endif
typedef struct _list{
    Node* head;
}List;
#include <stdio.h>
#include <stdlib.h>
void add(List *plist,int number); //在前面声明下

int main(void)
{
    List list;
    Node *head=NULL;
    int number;
    list.head=NULL;
    do{
        scanf("%d",&number);
        if(number!=-1){
            add(&list,number);
        }
    }while(number!=-1);
    head = list.head;
    while (head)
    {
        printf("%d\n", head->value);
        head = head->next;
    }
    return 0;
}
void add(List *plist,int number){

          Node *p=(Node*)malloc(sizeof(Node));
          p->value=number;
          p->next=NULL;
          Node *last;
          last=plist->head;  //去掉plist前面的*号
          if(last){
            while(last->next){
           last=last->next;
       }
          last->next=p;
    }else{
        plist->head=p;
    }
}

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

Line #36改为

last = plist->head;