#include #include #include #define MAX_NAME_LENGTH 100 #define MAX_BUFFER_LENGTH 256 #define SIZE 100 struct student { char name[SIZE]; int votes; }; struct student database[SIZE]; memset(database, 0, SIZE * sizeof(struct student)); int size = 0; char line[SIZE]; memset(line, 0, SIZE); char *r = fgets(line, SIZE, stdin); if (r == NULL) { // Nastal koniec vstupu } char *end = NULL; int value = strtol(line, &end, 10); if (value == 0) { // Prevod sa nepodaril } // Pre pokračovanie získame meno študenta char name[SIZE]; memset(name, 0, SIZE); char *name_start = end + 1; int name_length = strlen(name_start) - 1; // Nezahrňujeme koniec riadka if (name_length > 0) { memcpy(name, name_start, name_length); } else { // Nepodarilo sa načítať meno } int find_student(struct student *students, int size, const char *name) { for (int i = 0; i < size; i++) { if (strcmp(students[i].name, name) == 0) { return i; // Nájdený študent } } return 0; // Študent nenájdený } int id = find_student(database, size, name); if (id < 0) { // return 0; }