From 40192942a1f819672c5bab23ceb73d39f6e27f26 Mon Sep 17 00:00:00 2001 From: Oleksandr Hryshchenko Date: Fri, 5 Nov 2021 08:44:46 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'cv4/a=5Ftrain.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv4/a_train.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index e6c1958..1dd34aa 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -16,12 +16,12 @@ struct car* add_car(struct car* first, const char* target){ struct car* temp = first; - while(temp != NULL) + while(temp->next != NULL) temp = temp->next; - temp = (struct car*)calloc(1, sizeof(struct car)); - strcpy(temp->value, target); - temp->next = NULL; + temp->next = (struct car*)calloc(1, sizeof(struct car)); + strcpy(temp->next->value, target); + temp->next->next = NULL; return first; } @@ -73,13 +73,4 @@ struct car* clear_train(struct car* first, const char* target){ } return first; -} - -/*int main(){ - struct car* myCar = (struct car*)calloc(1, sizeof(struct car)); - myCar = add_car(myCar, "Kosice"); - print_train(myCar); - myCar = clear_train(myCar, "Kosice"); - print_train(myCar); - return 0; -}*/ \ No newline at end of file +} \ No newline at end of file