链队为什么插入不进去,显示异常

#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
typedef struct QNode {
	int data;                 //数据域
	struct QNode* next;       //指针域
}QNode;                       //队节点类型定义
typedef struct {
	QNode* front;                //对头指针
	QNode* rear;                //队尾指针
}LiQueue;                        //链队类型定义

int count = 0;
void initQueue(LiQueue* L);               //初始化一个链表
int isQueueEmpty(LiQueue* L);             //判断队列是否为空
void enQueue(LiQueue* L, int x);             //入队
int deQueue(LiQueue* L, int x);          //出队
//初始化链队算法
void
initQueue(LiQueue* L) {
	L = (LiQueue*)malloc(sizeof(LiQueue));
	if (NULL == L)
		printf("the malloc is error\n");
	L->front = L->rear = NULL;
	count = 0;
	printf("初始化成功!!!\n");
}
int
isQueueEmpty(LiQueue* L) {
	if (L->rear == NULL || L->front == NULL)
		return 0;
	else
		return 1;
}
//入队
void
enQueue(LiQueue* L, int x) {

	QNode* p;
	p = (QNode*)malloc(sizeof(QNode));
	p->data = x;
	p->next = NULL;
	printf("come!\n");  //第一次打印come
	if (L->rear == NULL)
	{
		L->front = L->rear = p;
		printf("come!\n");      //第二次打印come
	}
	else
	{
		L->rear->next = p;
		L->rear = p;
		printf("come!\n"); //第三次打印come
	}
	printf("入队成功!\n");
	count++;
	printf("%d", count);
}
//出队
int
deQueue(LiQueue* L, int x) {
	QNode* p;
	if (L->rear == NULL)
	{
		printf("wring!");
		return 0;
	}
	else
		p = L->front;
	if (L->front == L->rear)
		L->front == L->rear == NULL;      //只有有个节点时要特殊处理
	else
		L->front = L->front->next;
	x = p->data;
	free(p);
	count--;
	return 1;
}
int
main() {
	int doing, x, d;
	LiQueue List, * L;
	L = &List;
	doing = 1;
	while (doing) {
		printf("\n请选择您需要的功能:\n");
		scanf_s("%d", &doing);
		if (doing > 5 || doing < 0)
			printf("输入指令错误!\n");
		else
		{
			switch (doing)
			{
			case 1:
				initQueue(L);
				break;
			case 2:
				printf("请输入选择插入的人员:\n");
				scanf_s("%d", &x);
				printf("this\n");
				enQueue(L, x);     //插入队列算法         
				break;
			case 3:
				//	scanf_s("%d", &x);
				deQueue(L, x);
				break;
			case 4:
				if (L == NULL)
					printf("队列为空!\n");
				else
					printf("%d\n", count);
				break;

			}
		}
	}printf("后");
}

调用入队函数后 输入x值后就异常了

初始化函数写的不对。两种改法,一是将L作为返回值,不要作为参数;二是将参数改为**L,否则函数无法修改传入的L指针地址

void initQueue(LiQueue** L) {
	*L = (LiQueue*)malloc(sizeof(LiQueue));
	if (NULL == *L)
		printf("the malloc is error\n");
	*L->front = *L->rear = NULL;
	count = 0;
	printf("初始化成功!!!\n");
}