I have a Queue *q1, *q2 in main() that I send off the a function to initialize that looks like this:
Doesn't this create a brand new Queue, initialize it to NULL, then return it back to the calling function?Code:Queue *CreateQueue () { Queue *queue; queue->front = queue->rear = NULL; return queue; }
But what happens is that when I manipulate one queue, the exact same operation is performed on the other queue, as if they were the same queue.
From my other thread asking for queue help (http://cboard.cprogramming.com/showthread.php?t=57999), itsme86's queue initialization works fine because it creates QUEUE q1, q2; in main () before sending it off to be initialized:
Why doesn't my method work?Code:void new_queue(QUEUE *q) { q->head = q->tail = NULL; }