问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
#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'