From b628b7e76038472a260836bbdf0efda9ad36c60d Mon Sep 17 00:00:00 2001 From: VIliam Date: Mon, 4 Nov 2024 14:05:18 +0100 Subject: [PATCH] cv6 --- cv6/a_station.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index b018ffa..7b8b276 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -34,7 +34,7 @@ int index = select_track(station, target); current = current->next; } - // Ak ciel neexistuje, pridá novy zaznam do zoznamu + struct car* new_car = (struct car*)malloc(sizeof(struct car)); strncpy(new_car->value, target, TARGET_SIZE - 1); new_car->value[TARGET_SIZE - 1] = '\0'; @@ -44,7 +44,16 @@ int index = select_track(station, target); } int get_target_capacity(struct station* station,const char* target){ - return 0; +int index = select_track(station, target); + struct car* current = station->tracks[index]; + + while (current) { + if (strcmp(current->value, target) == 0) { + return current->capacity; + } + current = current->next; + } + return 0; } int count_targets(struct station* station){