为什么我的EnQueue会卡死,我总感觉是char数组出了问题
#include<iostream>
#include<malloc.h>
#include<stdio.h>
#include<string.h>
using namespace std;
typedef struct node{**//队列**
char name[20];
struct node *next;
}QType;
typedef struct lnode{//队头,队尾指针
QType *front;
QType *rear;
}LQueue;
void InitQueue(LQueue *&lq){//初始化队列
lq=(LQueue *)malloc(sizeof(LQueue));
lq->front=lq->rear=NULL;
}
void EnQueue(LQueue *&lq,char name[]){//插入队尾元素
QType *p;
p=(QType *) malloc (sizeof(QType));
strcpy(p->name,name);p->next=NULL;
if(lq->front=NULL)
lq->front=lq->rear=p;
else{
lq->rear->next=p;
lq->rear=p;
}
}
int ShowQueue(LQueue *lp){//输出队列元素
QType *p;
if(lp->front==NULL)return 0;
else{
p=lp->front;
cout<<"当前正在排队的有:";
while(p!=NULL){
cout<<" "<<p->name;
p=p->next;
}
}
}
int main(){
LQueue *p;
InitQueue(p); //初始化
char name[]="gggg";
EnQueue(p,name);**_//插入队尾元素 但是失败_**
ShowQueue(p);//输出元素
return 0;
}