链队列显示定义错误,运行不出来

实验要求是按约瑟夫环输出新队列
dad.c.exe 中的 0x00171875 处有未经处理的异常: 0xC0000005: 读取位置 0x00000004 时发生访问冲突

实验代码

#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#define maxsize 1024

typedef char datatype;
typedef struct node{
    datatype  data;
    struct node*next;
}QueueNode;  //链队列的结点类型

typedef struct{
     QueueNode *front, *rear;

 } LinkQueue;  //头、尾指针的结构体类型

int main()
{ void  InitQueue(LinkQueue*q);
  int DeQueue(LinkQueue*q, datatype x) ;
  void EnQueue (LinkQueue *q, datatype x);
  void Print(LinkQueue*q);
  int GetFront(LinkQueue*q,datatype&x);
  void josephus(LinkQueue*q,LinkQueue*r,int m);
  int i,r=3,m; 
  datatype x;
  char z;
  char *p[]={"雷震子","姜子牙","哪吒","申公豹","九尾狐","天尊", "太乙","杨戬","黄飞虎","纣王","李靖","土行孙"};
  LinkQueue*Q=0;
  InitQueue(Q);
  LinkQueue*W=0;
  InitQueue(W);
  LinkQueue*E=0;
  InitQueue(E);
  for(i=0;i<12;i++)
  EnQueue(Q,*p[i]);  
  Print(Q); 
  aa:printf("\n请先查看并选择从谁开始,再输入,格式例子为:雷震子,10\n");
  scanf("%s,%d",&z,&m);
  for(i=0;i<12;i++)
```c++



```c++



```c++
  { GetFront(Q,x);
    if(x==z)
    {printf("以%s开始报数,m=&d",z,m);
    break;}
    DeQueue(Q, x);
    EnQueue(Q, x);
  }
  if(x!=z)
   {printf("n输入错误请重新输入\n");
  goto aa;}
  josephus(Q,W,m);
  Print(Q);
  Print(W);
  josephus(W,E,r);
  Print(W);
  Print(E);
  return 0;
}

```c++


 void  InitQueue(LinkQueue*q)
 {q=(LinkQueue*)malloc(sizeof(LinkQueue));
```c++




``` //产生头、尾指针结构体
   q->front=q->rear=(QueueNode*)malloc(sizeof(QueueNode)); //产生头结点
   q->front->next=NULL; //头结点指针域置空
 }

 int Empty (LinkQueue*q)
 {if(q->front==q->rear)  return(1);
 else return(0);
 }

void EnQueue (LinkQueue *q, datatype x)
                                                //将新元素x加入链队列*q
 {q->rear->next=(QueueNode*)malloc(sizeof(QueueNode));
                                              // 新结点插入队尾
 q->rear=q->rear->next;  //尾指针指向新结点
 q->rear->data=x;       //给新结点赋值
 q->rear->next=NULL;   //队尾结点的指针域置空
 }

int DeQueue(LinkQueue*q, datatype x) 
        //通过参数x带回该元素值,出队成功返回1,不成功返回0
  
{    QueueNode*s;
if(Empty(q)){  printf("队列下溢");  return(0); }
else{  s = q->front->next;  //s指向被删除的队头结点 
if (s->next==NULL){  
             //当前链队列的长度等于1,出队后为空队 
    q->front->next=NULL;   
    q->rear=q->front ;  //置为空队 
} 
  else  q->front->next=s->next;

           //队列的长度大于1,修改头结点的指针域
  x=s->data; 
  free(s); //释放被删除的结点空间
  return(1); 
}
}

int GetFront(LinkQueue*q,datatype&x)
             //通过参数x带回队头元素值,取队头元素成功,返回1,不成功,返回0 
{  if(Empty (q))
         {   printf("队列下溢"); 
               return(0);}
else
{ x=q->front->next->data; 
return(1);
}
}


int Length(LinkQueue*q)
{QueueNode*p=q->front->next; int i=0;
while(p!=NULL)
{i++;  p=p->next;}
return i;
}

void Print(LinkQueue*q)
{QueueNode*p=q->front->next;
while(p!=NULL)
{    printf("%5d",p->data);   p=p->next;}
printf("\n");

}



void josephus(LinkQueue*q,LinkQueue*r,int m)
{     datatype n,i;
      int b;
      InitQueue(q);
      InitQueue(r);
     while(b)
    {    for(i=1;i<m-1;i++)
        {  b=DeQueue(q, n);
           EnQueue(q, n);
``


       if(b==0)
       break;
     }
      if(b==0)
        { printf("该处队列为空\n");
      break;}
      else


       b=DeQueue(q,n);
       EnQueue(r,n);
 }

}
`c++

```

你这初始化函数不行,不能改变外部指针地址