Code:
struct lista* del(struct lista* p, char* path1) {
char model[MAX2];
int len;
char ch;
printf("Type model.\n");
scanf("%s", model);
puts("\n");
struct lista* t = p;
if((strcmp(p->l.model, model)) == 0) {
t = p->next;
free(p);
return t;
}
while((t->next) != NULL) {
if((strcmp(t->l.model, model)) == 0) {
struct lista* e = t->next;
t->next = e->next;
free(e);
break;
}
t = t->next;
}
return p;
}
Hello, this function should delete each element in the list which is the same as this one typed by user. There are no errors, but function doesnt work. ![Frown](https://cboard.cprogramming.com/images/smilies/frown.png)
Can you please help me? ![Smile](https://cboard.cprogramming.com/images/smilies/smile.png)
EDIT:// It deletes something, but not this element which should.