我正在尝试将队列上的 C 程序作为链表。每当我尝试执行时,只要遇到 if 条件将指针(在本例中为 q->f)与 NULL 进行比较,它就会崩溃。请检查以下代码:
#include<stdio.h>
using namespace std;
struct node
{
int info;
node *next;
};
struct que
{
struct node *f; //front
struct node *r; //rear
que()
{
f=r=NULL; //initialize as NULL
}
};
struct que *pq;
/* prototypes */
void disp(struct que *q);
int emp(struct que *q);
void ins(struct que *q,int x);
void del(struct que *q);
int main()
{
int cho;
while(1) //so that it executes continuously and I can exit whenever I want …Run Code Online (Sandbox Code Playgroud)