From 2776b8204e54f638850857cf7ed5124cf5663964 Mon Sep 17 00:00:00 2001 From: Mohit Singh Date: Tue, 25 Sep 2018 23:50:38 +0530 Subject: [PATCH] Add main program for Message Queue --- .../MessageQueue-main.c | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Message Queue(Circular Queue)/MessageQueue-main.c diff --git a/Message Queue(Circular Queue)/MessageQueue-main.c b/Message Queue(Circular Queue)/MessageQueue-main.c new file mode 100644 index 0000000..97c28f0 --- /dev/null +++ b/Message Queue(Circular Queue)/MessageQueue-main.c @@ -0,0 +1,36 @@ +#include "MessageQueue.h" + +int main() +{ + int choice; + char message[100]; + queue q; + q.front = q.rear = -1; + while(1) + { + printf("Current Queue: "); + display(&q); + printf("\n Front = %d Rear = %d", q.front, q.rear); + printf("\n 1. Enqueue message \n 2. Dequeue message \n 3. Display Queue \n 4. EXIT\n"); + scanf("%d",&choice); + switch(choice) + { + case 1: + printf("Enter message to be inserted : "); + scanf("%s", message); + enqueue(&q, message); + break; + case 2: + dequeue(&q); + break; + case 3: + display(&q); + break; + case 4: + exit(0); + default: + printf("Invalid Choice.\n"); + } + } + return 0; +}