This is the part of a program for implementing queue with ring buffer in C.
And I don't understand the line 8-9.
What exactly does this line if(q->rear == q->max) q->rear = 0;
mean?
if the rear index equals the max capacity... then assign zero to rear? T_T Help me please!
int Enque(IntQueue* q,int x)
{
if (q->num >= q->max)
return -1;
else {
q->num++;
q->que[q->rear++] = x;
if(q->rear == q->max)
q->rear = 0;
return 0;
}
}