user-0 提问: 请大佬帮忙看下这段代码为什么出队不成功

回复:
user: user-1
content: 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10581430.html 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10768339.html

user: user-2
content: #include<stdio.h> #include<stdlib.h>  #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 #define OVERFLOW -2  typedef int Status;  typedef struct QNode {     int data;     struct QNode *next; }QNode, *QueuePtr;  typedef struct LinkQueue{     QueuePtr front;     QueuePtr rear; }LinkQueue;//队列类型  Status Queue_Clear(LinkQueue *Q);   Status Queue_Init(LinkQueue *Q) {     QNode *head;     head = (QNode *)malloc(sizeof(QNode));     if (!head)         return OVERFLOW;     Q->front = Q->rear = head;     Q->front->next = NULL;     return OK; }  Status Queue_Destroy(LinkQueue *Q) {     Queue_Clear(Q);      free(Q->front);     Q->front = Q->rear =  NULL;     /*     while (Q->front->next) {         Q->rear = Q->front->next->next;         free(Q->front->next);         Q->front->next = Q->rear;     }     free(Q->front);     Q->front = NULL;     */     return OK; }  Status Queue_Clear(LinkQueue *Q) {      QueuePtr pcur = Q->front->next;     while (pcur) {         Q->front->next = pcur->next;         free(pcur);         pcur = Q->front->next;     }     Q->rear = Q->front;     //Q->front->next = NULL;     /*     while (Q->front->next)     {         Q->rear = Q->front->next->next;         free(Q->front->next);         Q->front->next = Q->rear;     }     Q->rear = Q->front;     Q->front->next = NULL;     */     return OK; }  Status Queue_Empty(LinkQueue *Q) {     if (Q->front == Q->rear)         return OK;      return FALSE; }  int Queue_Length(LinkQueue *Q) {     int length = 0;     QueuePtr pcur = Q->front->next;      while (pcur) {         length++;         pcur = pcur->next;     }     /*        while (Q.front->next) {        length++;        Q.front->next = Q.front->next->next;        }        */     return length; }  Status Queue_Get_First_Element(LinkQueue Q, int *first_element) {     if (Q.front == Q.rear)         return ERROR;     first_element = &Q.front->next->data;     return OK; }  Status Queue_Enter(LinkQueue *Q, int new_element) {     QNode *new_node;     new_node = (QueuePtr)malloc(sizeof(QNode));     if (!new_node)         return OVERFLOW;     new_node->data = new_element;     new_node->next = NULL;     Q->rear->next = new_node;     Q->rear = new_node;      return OK; }  Status Queue_Delete(LinkQueue *Q, int *delete_element) {     QueuePtr pdel = NULL;     if (Q->front == Q->rear)         return ERROR;     //delete_element = Q->front->next->data;     *delete_element = Q->front->next->data;     pdel = Q->front->next;     Q->front->next = Q->front->next->next;     if (pdel == Q->rear)         Q->rear = Q->front;     free(pdel);     /*     if (Q->front->next == Q->rear) Q->rear = Q->front;     free(Q->front->next);     */     return OK; }  int main() {     Status function_status;     LinkQueue *linkqueue;     int new_element;     int delete_element;     int queue_length = 0;     int count = 0;      linkqueue = (LinkQueue*)malloc(sizeof(LinkQueue));     function_status = Queue_Init(linkqueue);     if (function_status == OK)         printf("\r\n初始化链队列成功！\r\n");     if(function_status == OVERFLOW) {         printf("\r\n初始化链队列失败！\r\n");          return -1;     //初始化失败是不是就应该直接退出呢，后面执行会出问题的     }     //queue_length = Queue_Length(*linkqueue);     queue_length = Queue_Length(linkqueue);     printf("\r\n初始化链队列成功后队列长度为：%d\r\n", queue_length);     function_status = Queue_Empty(linkqueue);     if (function_status == OK)         printf("\r\n链队列为空队列！\r\n");     if (function_status == ERROR)         printf("\r\n链队列为非空队列！\r\n");      queue_length = Queue_Length(linkqueue);     printf("\r\n空链队列长度为：%d\r\n", queue_length);      printf("\r\n请输入三个新的整形元素：");     for (count = 0; count <= 2; count++)     {         scanf("%d", &new_element);         Queue_Enter(linkqueue, new_element);     }     queue_length = Queue_Length(linkqueue);     printf("\r\n元素入队后队列长度为：%d\r\n", queue_length);      function_status = Queue_Delete(linkqueue, &delete_element);     if (function_status == OK)         printf("\r\n元素%d出队成功！\r\n", delete_element);     if (function_status == ERROR)         printf("\r\n元素出队失败！\r\n");      queue_length = Queue_Length(linkqueue);     printf("\r\n一个元素出队后队列长度为：%d\r\n", queue_length);     printf("\n");      Queue_Destroy(linkqueue);     return 0; }  供参考～