#include "a_station.h" #include #include #include #define MAX_INPUT 100 void test_station(struct station* station) { char station_name[MAX_INPUT]; int capacity; printf("Enter station name and capacity (or 'exit' to stop):\n"); while (1) { printf("Station name: "); if (!fgets(station_name, MAX_INPUT, stdin)) break; // Remove trailing newline station_name[strcspn(station_name, "\n")] = '\0'; if (strcmp(station_name, "exit") == 0) break; printf("Capacity: "); if (scanf("%d", &capacity) != 1) { printf("Invalid input. Try again.\n"); while (getchar() != '\n'); // Clear input buffer continue; } // Clear input buffer while (getchar() != '\n'); add_target_capacity(station, station_name, capacity); int track = select_track(station, station_name); printf("Track for %s: %d\n", station_name, track); int current_capacity = get_target_capacity(station, station_name); printf("Current capacity to %s: %d\n\n", station_name, current_capacity); } printf("Final Statistics:\n"); printf("Total number of targets: %d\n", count_targets(station)); printf("Total capacity: %d\n", count_capacity(station)); } int main() { struct station* station = create_station(); test_station(station); destroy_station(station); return 0; }