From cecb28932b7eb0e5638243d4f7aca778ee512b0e Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Thu, 5 Nov 2020 19:39:07 +0100 Subject: [PATCH] 15% --- cv5/a_train.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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++; }