I'm new to C and I'm trying to code a queue problem. At the moment, I'm coding something that will check if the queue is empty. This is what I have so far:
For Queue.h (this was provided by our instructor)
#include <stdio.h>
#include <stdlib.h>
struct queueNode {
char data;
struct queueNode *nextPtr;
};
typedef struct queueNode QueueNode;
typedef QueueNode* QueueNodePtr;
typedef struct Queue {
QueueNodePtr head;
QueueNodePtr tail;
} Queue;
void instructions();
int isEmpty(Queue);
void enqueue(Queue*, char);
char dequeue(Queue*);
void printQueue(Queue);
void freeQueue(Queue*);
For Queue.c
#include <stdio.h>
#include <stdlib.h>
#include "Queue.h"
int isEmpty(struct Queue queue)
{
if (Queue == NULL)
{
return 1;
}
}
The problem is in line 8 of Queue.c, the compiler says "error: expected expression before 'Queue'" How will I resolve this?
Edit: I tried to use queue == NULL instead of Queue == NULL and the compiler said: error: invalid operands to binary == (have 'struct Queue' and 'void*').
Thank you very much!
Queueis the name of a struct. The expressionQueue == NULLis trying to compare a type name to a value. The parameterstruct Queue queuepasses your queue by value, which might not be what you want. All things considered, it's absolutely unclear how to answer this, as it probably depends on the semantics of your structure itself. I suggest you edit your question to show the contents ofQueue.h.gcc -Wall -Wextra -g(all warnings and debug info). Take inspiration from existing programs coded in C on github