This commit is contained in:
Maryna Kravtsova 2020-11-02 13:13:53 +01:00
parent 3a019b60f2
commit 29fb081da8

View File

@ -6,14 +6,15 @@
struct car* add_car(struct car* first,const char* target) { struct car* add_car(struct car* first,const char* target) {
struct car* newcar = calloc(1, sizeof(struct car)); struct car* newcar = calloc(1, sizeof(struct car));
if(target == NULL){
exit(0);
}
strcpy(newcar->value, target); strcpy(newcar->value, target);
if(first == NULL){ if(first == NULL){
return newcar; return newcar;
} }
if(target == NULL){
return NULL;
}
struct car *this = first; struct car *this = first;
while(this->next != NULL){ while(this->next != NULL){
this = this->next; this = this->next;
@ -40,7 +41,6 @@ void cancel_train(struct car* first) {
exit(0); exit(0);
} }
if(first->next == NULL){ if(first->next == NULL){
printf("Tam je null");
struct car* this = first; struct car* this = first;
first = first->next; first = first->next;
free(this); free(this);