I am implementing Priority Queue of int
in C. I have a struct Node
in my header
typedef struct NodeTag {
int priority;
int value;
struct Node *next;
}Node;
Now in my C file I am trying to add a new element while traversing the queue and comparing the priorities values of each element inside with the new one. So I try to do this
Node *prev = head;
while(prev->next && prev->next->priority >= priority){
prev=prev->next;
}
temp->next=prev->next;
prev->next=temp;
But I get a compiler error saying:
incomplete definition of type 'struct Node'
On my while condition. How to access the property of priority of the next node of prev
?