diff --git a/cv5/a_train.c b/cv5/a_train.c index b6d2b6a..90d254d 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -6,14 +6,15 @@ struct car* add_car(struct car* first,const char* target) { struct car* newcar = calloc(1, sizeof(struct car)); + if(target == NULL){ + exit(0); + } + strcpy(newcar->value, target); if(first == NULL){ return newcar; } - if(target == NULL){ - return NULL; - } struct car *this = first; while(this->next != NULL){ this = this->next; @@ -40,7 +41,6 @@ void cancel_train(struct car* first) { exit(0); } if(first->next == NULL){ - printf("Tam je null"); struct car* this = first; first = first->next; free(this);