50 lines
1017 B
C
50 lines
1017 B
C
#include "a_train.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
struct car* add_car(struct car* first, const char* target) {
|
|
struct car* new_car = (struct car*)malloc(sizeof(struct car));
|
|
if (new_car == NULL) {
|
|
printf("Chyba: Nepodarilo sa alokovať pamäť pre nový vozeň.\n");
|
|
return first;
|
|
}
|
|
strncpy(new_car->value, target, SIZE);
|
|
new_car->next = NULL;
|
|
|
|
if (first == NULL) {
|
|
return new_car;
|
|
}
|
|
|
|
struct car* temp = first;
|
|
while (temp->next != NULL) {
|
|
temp = temp->next;
|
|
}
|
|
temp->next = new_car;
|
|
|
|
return first;
|
|
}
|
|
|
|
void print_train(struct car* first) {
|
|
if (first == NULL) {
|
|
printf("Vlak je prazdny.\n");
|
|
return;
|
|
}
|
|
|
|
struct car* temp = first;
|
|
while (temp != NULL) {
|
|
printf("Cielova stanica: %s\n", temp->value);
|
|
temp = temp->next;
|
|
}
|
|
}
|
|
|
|
void cancel_train(struct car* first) {
|
|
|
|
}
|
|
|
|
|
|
struct car* clear_train(struct car* first, const char* target) {
|
|
return NULL;
|
|
}
|
|
|