This is an old revision of the document!
While stacks followed LIFO (last in first out) queues follow FIFO (First in First out).
Here is a simple struct you can implement for your queue structure:
struct queue { cardnode* front; // Pointer to the front of the queue cardnode* rear; // Pointer to the rear of the queue int size; // Size of the queue };
The provided struct consists of a front and rear pointer of a queue along with a size variable.
Once you have created your struct for your queue you can optionally create a function to call every time you want to make a queue. If you are creating the card game War(highly recommended) this is not necessary but helps clean up your program.
Here is an example of a function that creates a queue:
// Function that creates and initializes a new deck structure deck* createDeck() { deck* newDeck = (deck*)malloc(sizeof(deck)); newDeck->start = NULL; newDeck->end = NULL; newDeck->size = 0; return newDeck; }