版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39642794/article/details/81606793
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)已经讲了为什么不可以 这样属于无效指针;