I am trying to delete a node in the middle of my linked list. I am having some trouble...anyone see where my problem is?
Code:
void *cancelFlight(struct llnode **flight, char firstName[], char lastName[])
{
struct llnode *newlist;
struct llnode *current;
int stop = 0;
current = (struct llnode*) malloc(sizeof(struct llnode));
newlist = (struct llnode*) malloc(sizeof(struct llnode));
current = *flight;
newlist = *flight;
if(strcmp(current->lastName, lastName) == 0 && strcmp(current->firstName,firstName) == 0)
{
newlist = newlist->next;
*flight = newlist;
}
else
{
while(stop == 0)
{
current = current->next;
if(strcmp(current->lastName, lastName) == 0 && strcmp(current->firstName,firstName) == 0)
{
current = current->next;
newlist->next = current;
*flight = newlist;
stop = 1;
}
}
}
}