This commit is contained in:
Maryna Kravtsova 2020-11-02 15:35:42 +01:00
parent 33dc166873
commit da2607343b

View File

@ -6,15 +6,16 @@
#include "a_train.h" #include "a_train.h"
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));
if(target == NULL){ if(target == NULL){
exit(0); return 0;
} }
strcpy(newcar->value, target);
if(first == NULL){ if(first == NULL){
return newcar; return newcar;
} }
struct car* newcar = calloc(1, sizeof(struct car));
strcpy(newcar->value, target);
struct car *this = first; struct car *this = first;
while(this->next != NULL){ while(this->next != NULL){
this = this->next; this = this->next;