if it is FIFO, the oldest is the tail of the list isn'it?
Code:
if((pnt->next)==NULL)
{ c=head->nodecode;
h=NULL;
printf("%d\n",c);
}
Here you're telling: if the list has only one node, take its number. you are not deleting anything.
Code:
else{
c=head->nodecode;
printf("%d\n",c); //now prints the variable that deletes but it's the most recent -.-'
head=pnt->next;
free(pnt);
}
in this case you are taking the node number of the first element, moving the head to the next node, and deleting the first node! of course it deletes the latest entry.
This should work:
Code:
int dequeue(NODEPTR pnt, NODEPTR h)
{int c;
pnt=h;
NODEPTR prev=pnt;
while(pnt->next!=NULL) {
prev=pnt;
pnt=pnt->next;
}
c=pnt->nodecode;
printf("%d\n",c);
free(pnt);
prev->next=NULL;
h=pnt->next;
return c;
}