链式队列的问题
程序代码:
/* Note:Your choice is C IDE */ #include "stdio.h" #include "malloc.h" #include "string.h" typedef struct node { char s[10]; struct node *next; }linknode; typedef struct { linknode *front; linknode *rear; }Qnode; int chushihua(Qnode * q) //初始化队列 { q->front=(linknode *)malloc(sizeof(linknode)); if(q->front!=NULL) { q->rear=q->front; q->front->next=NULL; return 1; } else return 0; } int fuzhi(Qnode *Q) //入列 { linknode *s; s=(linknode * )malloc(sizeof(linknode)); if(s!=NULL) { strcpy(s->s,"wsliuyun"); s->next=NULL; Q->rear->next=s; Q->rear=s; return 1; } else return 0; } int chulie(Qnode *s) //出列 { char ch[10]; linknode *p; if(s->front==s->rear) return 0; p=s->front->next; s->front->next=p->next; if(s->rear==p) s->rear=s->front; strcpy(ch,p->s); printf("%s",ch); free(p) ; return 1; } void main() { Qnode *Q; chushihua(Q); fuzhi(Q); chulie(Q); }运行出现错误提示 该内存不能为“written”. 帮帮忙 谢谢。。。