for some reason every time i try to delete the plate from the linked list, it returns a zero value. i know that
Code:
while(crnt->next !=NULL && crnt->next->license != license)
{
crnt = crnt->next;
}
is where i am having my problem. it isnt searching for the value and is hitting null to return 0. what am i doing wrong?
Code:
int removecar(struct cars** head, char* license)
{
struct cars* temp;
struct cars* crnt;
if((*head) == NULL)
return 0;
if((*head)->license == license)
{
temp = *head;
(*head) = (*head)->next;
free(temp);
return 1;
}
crnt = *head;
while(crnt->next !=NULL && crnt->next->license != license)
{
crnt = crnt->next;
}
if(crnt->next==NULL) //end of list reach and plate not found
return 0;
temp = crnt->next;
crnt->next = crnt->next->next;
free(temp);
return 1;
}