clear
This commit is contained in:
parent
3ff32fafa1
commit
97472d25cf
@ -64,11 +64,16 @@ struct car* clear_train(struct car* first, const char* target) {
|
||||
while(first != NULL){
|
||||
int x = strcmp(this->value, target);
|
||||
if(x == 0){
|
||||
struct car* temp = this->next;
|
||||
strcpy(this->value,temp->value);
|
||||
free(temp);
|
||||
free(temp->value);
|
||||
return 0;
|
||||
struct car* prev = this;
|
||||
struct car* node = this->next;
|
||||
while(prev != NULL && node != NULL){
|
||||
prev->next = node->next;
|
||||
free(node);
|
||||
prev = prev->next;
|
||||
if(prev != NULL){
|
||||
node = prev->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
this = this->next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user