Update cv4/a_train.c

This commit is contained in:
Marat Izmailov 2024-10-17 17:49:18 +00:00
parent c35da2220c
commit e1c4306436

View File

@ -5,14 +5,14 @@
struct car* add_car(struct car* first, const char* target) { struct car* add_car(struct car* first, const char* target) {
struct car* newcar = (struct car*)calloc(1, sizeof(struct car)); struct car* newcar = (struct car*)calloc(1, sizeof(struct car));
if (newcar == NULL) { if (newcar == NULL) {
printf("Ошибка: не удалось выделить память.\n"); printf("Chyba: nepodarilo sa alokovať pamäť.\n");
exit(1); exit(1);
} }
strcpy(newcar->value, target); strcpy(newcar->value, target);
newcar->next = NULL; newcar->next = NULL;
if (first == NULL) { if (first == NULL) {
return newcar; return newcar;
@ -32,12 +32,12 @@ void print_train(struct car* first) {
struct car* current = first; struct car* current = first;
if (current == NULL) { if (current == NULL) {
printf("Поезд пуст.\n"); printf("Vlak je prázdny.\n");
return; return;
} }
while (current != NULL) { while (current != NULL) {
printf("%s\n", current->value); printf("%s\n", current->value);
current = current->next; current = current->next;
} }
} }
@ -74,7 +74,6 @@ struct car* clear_train(struct car* first, const char* target) {
current = current->next; current = current->next;
} }
} }
return first; return first;
} }