Pointers to structures
- by blacktooth
typedef struct queue {
int q[max];
int qhead;
int qrear;
} queue;
void init_queue(queue *QUEUE)
{
QUEUE.qhead = 0;
QUEUE.qrear = -1;
}
void enqueue(queue *QUEUE,int data)
{
QUEUE.qrear++;
QUEUE.q[QUEUE.qrear] = data;
}
int process_queue(queue *QUEUE)
{
if(QUEUE.qhead > QUEUE.qrear)
return -1;
else
return QUEUE.q[QUEUE.qhead++];
}
I am implementing queues using arrays just to keep it simple. Wats the error with the above code?