typedef struct Node
{
int data;
struct Node *next;
}Qnode;
typedef struct
{
Qnode *front,*rear;
}Linkqueue;
Linkqueue *Q;
头尾指针是属于一个结构体,相当于一个结构体有这两个值。
开辟内存:
Q=(Linkqueue *)malloc(sizeof(Qnode));
Q->front=Q->rear= (Qnode *) malloc(sizeof(Qnode));
Q->front->next=Q->rear->next=NULL;
不能写成Q->front=Q->rear=NULL在上一篇博客(p->next=NULL和p=NULL)已经讲了为什么不可以 这样属于无效指针;