hi iv got a problem every time i try to remove a pice of data from my queue when it is already empty it crashes cmd and i dont understand why i was wondering if anyone could help me
is is menu driven here are the relevent sections
Code:
case 2:
strcmp(szReg,leave(&taxiQueue));
if(szReg == NULL)
{
printf("there are no taxis in the queue to leave");
}
else
{
printf("\nTaxi %s was removed from the queue",szReg);
}
break;
and the function
Code:
char *leave(TaxiQueue *tq)
{
Taxi **front = &tq->pFront;
Taxi **back = &tq->pBack;
char *reg = malloc(sizeof(char) * 20);
// Test if the queue is empty
if((*front) == NULL && (*back) == NULL)
{
// Nothing in queue
return NULL;
}
else if((*front) == (*back))
{
// The front and back are the same
strcpy(reg,(*front)->szReg);
// Delete the taxi
free((*front));
// Set the front and back to null
(*front) = NULL;
(*back) = NULL;
tq->iLength--;
return reg;
}
else
{
strcpy(reg,(*front)->szReg);
// Remove from the front
(*front) = (*front)->pNext;
free((*front)->pPrev);
(*front)->pPrev = NULL;
tq->iLength--;
return reg;
}
return NULL;
}
i think iv got a case of looking at it so long my brain imagines that theres nothing wrong lol