Update cv4/a_train.c

This commit is contained in:
Yurii Yakovenko 2024-10-23 19:55:03 +00:00
parent b19bc58d10
commit 76864bd125

View File

@ -1,11 +1,12 @@
#include <stdio.h> #include <stdio.h>
#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* ret = first;
struct car* nc=(struct car*) malloc(sizeof(struct car)); struct car* nc=(struct car*) malloc(sizeof(struct car));
strcpy(nc->value, target); strcpy(nc->value, target);
nc->next=NULL; nc->next=NULL;
@ -17,7 +18,7 @@ struct car* add_car(struct car* first,const char* target)
first=first->next; first=first->next;
} }
first->next=nc; first->next=nc;
return first; return ret;
} }
first=nc; first=nc;