This commit is contained in:
Maryna Kravtsova 2020-11-02 12:12:53 +01:00
parent d8021186e1
commit 8afedc84ac

View File

@ -7,9 +7,13 @@
struct car* add_car(struct car* first,const char* target) {
struct car* newcar = calloc(1, sizeof(struct car));
strcpy(newcar->value, target);
if(first == NULL){
return newcar;
}
if(first->next == NULL){
first->next = newcar;
}
struct car *this = first;
while(this->next != NULL){
this = this->next;
@ -36,6 +40,7 @@ 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);