diff --git a/cv5/a_train.c b/cv5/a_train.c index c24a1aa..23fe54c 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -14,11 +14,12 @@ struct car* add_car(struct car* first,const char* target) { struct car* newcar = calloc(1,sizeof(struct car)); - struct car* temp=first; + struct car* this=first; int length=0; - while(temp!=NULL){ - if(temp->next!=NULL){ - temp=temp->next; + while(this!=NULL){ + if(this->next!=NULL){ + this=this->next; + this->next = newcar; } length++; }