[Error] 'head' was not declared in this scope 为啥是这个错误啊
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#define LEN sizeof(Node)
typedef struct _node
{
int value;
struct _node*next;
}Node;
typedef struct _list
{
Node* head;
}List;
void add(Node* head,int number);
int main(int agrc,char const *agrv[])
{
List list;
int number;
list.head=NULL;
head=(List *)malloc(sizeof(List));
do
{
scanf("%d",&number);
if(number!=-1)
{
head=add(&list,number); 《————错误在这,而且有两个 还有一个是[Error] cannot convert 'List* {aka _list*}' to
'Node* {aka _node*}' for argument '1' to 'void add(Node*, int)'
}
}while(number!=-1);
Node *p;
for(p=list.head;p;p=p->next)
{
printf("%d\t",p->value);
}
return 0;
}
void add(List* pList,int number)
{
Node *p=(Node*)malloc(sizeof(Node));
p->value=number;
p->next=NULL;
Node *last=pList->head;
if(last)
{
while(last->next)
{
last=last->next;
}
last->next=p;
}
else
{
pList->head=p;
}
}