i seem to be having a problem printing a queue. when i dequeue, i am returning the value that was dequeued, and letting the user know when the queue is empty, but when i go to print the queue, the values entered are still there. i think it has to do with my dequeue function. here's the code
Code://in main if choice = 6 then print the queue if(choice == 6) { print_queue(q); } //remove the front value int dequeue(struct queue* q) { int val = q->store[q->front]; q->front = (q->front + 1) % q->size; return val; } //print queue function void print_queue(struct queue* q) { int j; for(j=0; j < q->back; j++) printf("%d ", q->store[j]); printf("\n"); }



LinkBack URL
About LinkBacks


