Code:
void QueueFront (QueueEntry *x, Queue *q)
{
if (QueueEmpty (q))
Error('Queue is empty.");
else
q->entry[q->front] = x;
}
If QueueEntry is an integer, and q->entry [i] is also an integer, then q->entry[q->front]=x should be q->entry[q->front]=*x;
Can you give the specifications of the functions? To me it seems that x is in output variable. So I would expect:
Code:
void QueueFront (QueueEntry *x, Queue *q)
{
if (QueueEmpty (q))
Error('Queue is empty.");
else
*x = q->entry[q->front];
}
It's just a matter of interpretation. But what I mean is: please make clear what your programs do, perhaps using pre- and postconditions, and show us what your datatypes are. Queue doesn't tell us very much. Though I guess it's a structure with an array and some variables in it.