Skip to content

Commit

Permalink
Add main program for Message Queue
Browse files Browse the repository at this point in the history
  • Loading branch information
msindev committed Sep 25, 2018
1 parent 1637cfe commit 2776b82
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Message Queue(Circular Queue)/MessageQueue-main.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 2776b82

Please sign in to comment.