This commit is contained in:
Anton Dolozin 2025-10-28 21:16:46 +01:00
parent 524c7c235c
commit 35c325dd8f

View File

@ -63,8 +63,17 @@ struct car* clear_train(struct car* first, const char* target) {
} }
struct car* prev= first; struct car* prev= first;
struct car* temp = first->next; struct car* temp = first->next;
while (temp) while (prev && temp)
{ { if (strcmp(prev, target) == 0)
{ struct car* targetNode =prev;
prev = temp;
temp = temp->next;
free(targetNode);
/* code */
}
if(strcmp(temp->value, target) == 0){ if(strcmp(temp->value, target) == 0){
struct car* targetNode = temp; struct car* targetNode = temp;
prev->next = temp->next; prev->next = temp->next;