Hi all
I'm having kind of queue problem in my program while handling queues,,
basicly in my program I have 4 different quees , you can try to think like, there are 2 different cities
and 2 different airports, and 1 takeoff and 1 landing queues an..Totally I've got 4 different linked list...
Every take off queues consist of just 2 item, landing has got no limit...
User fill in the queues in the begining of program by enterin two item into every queue list.
like
A city Take Off--> x-y
A City Landing--> k-f
B city take off--> p-m
B city take off--> j-t
After user filled in by entering char names like above,
User enters a direction like A to B
and
Program Takes first element of A City's takeoff and transfers it into B city's landing,
like so
A to B
A city take off--> Y
A city Landing--> K F
B city take off--> P M
B city landing --> X - J- T
while doing this I'm using tradational enqueue and dequeue functions but I'm having a problem while
transfering A link's one element to B link...
here is the a part of the code
Code:
if(flight_choice=='I');{choice=1;}
if(flight_choice=='A');{choice=2;}
if(flight_choice=='E');{choice=3;}
switch(choice){
case 1:
flight_choice2=getch();
flight_choice2=toupper(flight_choice2);
printf("%c\n",flight_choice2);
if(flight_choice2 == 'A'){
dequeue(&ist_take_head,&key1);
enqueue(&ank_land_head,key1);
dequeue(&ist_land_head,&key1);
enqueue(&ist_take_head,key1);
}
void enqueue( flight** head, char key )
{
flight* newNode = malloc(sizeof(flight));
newNode->key = key;
newNode->next = NULL;
if ( *head == NULL )
{
*head = newNode;
}
else
{
flight* last = *head;
while ( last->next != NULL )
last = last->next;
last->next = newNode;
}
}
void dequeue(flight** head, char *key) {
if ( *head == NULL )
{
*key = 0;
}
else
{
*key = (*head)->key;
*head = (*head)->next;
}
}
What I dont understand is what I have to pass as a key,while doing dequeue function the key(which is the name of element in the linked list),
I pass into that function.
I know it's not a clear explanation but I got totally confused so that I cant excatly explain my question .