I have written a piece of code for queue.
#include <iostream>
using namespace std;
struct q
{
int items[10];
int front,rear;
} queue;
void Addqueue(struct q *queue, int item)
{
if (queue->rear==9)
cout << "Queue is Full.";
else
queue->items[++queue->rear]=item;
}
int main()
{
queue.front=queue.rear=-1;
Addqueue(q *queue,5);
return 0;
}
As you can see I have used struct object for it. In Addqueue Function, first element is (struct q *queue), I want to know what should I write instead of it, while I'm caling this function in main function, for example I tested Addqueue(q *queue,5) and Addqueue(queue,5) and Addqueue(*queue,5) and Addqueue(struct q *queue,5), but none of them works and I will get an error for this line. so what should I do? what is wrong?