I'm creating a program that needs to be able to create/handle a number of queues. I used this code to work with 1 queue in programs. If I wanted to add more queues based on this code how exactly do I do it? And will there be a problem if each queue's size is varying depending on random number generation?
typedef int Item;
typedef struct node *link;
struct node{
Item data;
link next;
};
int QUEUEempty(link head){
return head == NULL;
}
void QUEUEput(link *head, link *tail, Item data){
if (*head == NULL){
(*tail) = (link)malloc(sizeof(node));
(*tail)->data = data;
(*tail)->next = NULL;
*head = *tail;
return;
}
(*tail)->next = (link)malloc(sizeof(node));
*tail = (*tail)->next;
(*tail)->data = data;
(*tail)->next = NULL;
return;
}
Item QUEUEget(link *head){
Item data = (*head)->data;
link t = *head;
*head = (*head)->next;
free(t);
return data;
}