c语言,链表出现读取访问权限冲突

#include <stdio.h>
#include <stdlib.h>

typedef struct _node {
	int value;
	struct _node* next;
}Node;

typedef struct _list {
	Node* head;
}List;

void add(int number, List* pList);

int main()
{
	int number;
	Node* head = NULL;
	List list;

	do {
		scanf_s("%d", &number);
		if (number != -1) {
			add(number,&list);
		}
	} 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 = pList->head;
	if (last) {
		while (last->next) {
			last = last->next;
		}
		last->next = p;
	}
	else {
		pList->head = p;
	}
}

请问各位大佬,链表出现了“读取访问权限冲突”,刚写完这段代码还能正常运行,后来就出现读取访问权限冲突。

代码能run,调试的时候发现是add函数把number传过去的时候出现问题,到底是出了什么问题呢?

main函数中的局部变量list没有初始化,导致list.head是一个随机值,传递给add后,last也是一个随机值。

#include <stdio.h>
#include <stdlib.h>

typedef struct _node {
	int value;
	struct _node* next;
}Node;

typedef struct _list {
	Node* head;
}List;

void add(int number, List* pList);
//void print(List* pList);

int main()
{
	int number;
	
	List list;
	list.head = NULL;//这里我将list.head初始化了
	do {
		scanf_s("%d", &number);
		if (number != -1) {
			add(number,&list);
		}
	} while (number != -1);
	//print(&list);
	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;
	}
}

楼上那位大哥,我把list.head = NULL;之后,就出现了下面的问题

你这里的声明和实现对不上,是不是调用到其他地方去了