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;