From 2e25765e5d90fe45a38db591666461517fab628e Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 20 Oct 2024 12:58:05 +0000 Subject: [PATCH] Initializacia --- cv4/a_train.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 4be60ce..f881ba2 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -3,20 +3,22 @@ #include #include -struct car* add_car(struct car* first,const char* target) { +struct car* add_car(struct car* first, const char* target) { struct car* last = first; - struct car* newcar* = calloc(1, sizeof(struct car)); + struct car* newcar = calloc(1, sizeof(struct car)); strcpy(newcar->value, target); - if (last != NULL){ + + if (last != NULL) { struct car* current = last; - while(current->next != NULL){ - current = current->next + while (current->next != NULL) { + current = current->next; } current->next = newcar; - } else{ + } else { last = newcar; return last; } + return first; }