From da2607343b673fdaca4e93168804e0eb0fbfbd0a Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Mon, 2 Nov 2020 15:35:42 +0100 Subject: [PATCH] add --- 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 46157e3..2708199 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -6,15 +6,16 @@ #include "a_train.h" struct car* add_car(struct car* first,const char* target) { - struct car* newcar = calloc(1, sizeof(struct car)); if(target == NULL){ - exit(0); + return 0; } - strcpy(newcar->value, target); - if(first == NULL){ return newcar; } + + struct car* newcar = calloc(1, sizeof(struct car)); + strcpy(newcar->value, target); + struct car *this = first; while(this->next != NULL){ this = this->next;