How to write a C program to defines a generic type for queues in C Programming Language ?
This C program defines a generic type for queues.
Solution:
- /* This C program defines a generic type for queues. */
- #ifndef QUEUE_H
- #define QUEUE_H
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- typedef struct Queue Queue;
- typedef int Queueelem;
- Queue *queue_new(unsigned long queue_size);
- bool queue_is_empty(const Queue *q);
- void queue_add(Queue *q, Queueelem elem);
- Queueelem queue_get(Queue *q);
- void queue_show(const Queue *q);
- void queue_delete(Queue *q);
- #endif