#include #include #include #include #include #define SIZE 128 int najdi_studenta(struct student* students,int size, const char* name); int main() { //pomocne premeny struct student databaza[SIZE]; memset(databaza,0,SIZE*sizeof(struct student)); int size = 0; char line[SIZE]; memset(line,0,SIZE); char* r = fgets(line,SIZE,stdin); if (r == NULL) { printf("Chyba: Zlyhalo nacitavanie vstupu.\n"); } char meno[SIZE]; memset(meno,0,SIZE); char* zaciatokMena = konecPtr + 1; int size_mena = strlen(zaciatokMena) - 1; if (size_mena > 0) { memcpy(meno,zaciatokMena,size_mena); } else { printf("Chyba: Nepodarilo sa nacitat meno.\n"); } char* konecPtr = NULL; int value = strtol(line,&end,10); if (value == 0) { printf("Chyba: Zlyhala premena vstupu.\n"); } int id = find_student(databaza,size,meno); if (id < 0) { memcpy(databaza.name,meno,velkost_mena); size+=1; } else { s1.votes += 1; } return 0; } int najdi_studenta(struct student* students,int size, const char* name) { for (int i = 0; i < size, i++) { if (struct student databaza[i] == name) { return i; } } return -1; } struct student { char name[SIZE]; int votes; }; int komparator(const void* p1, const void* p2) { struct student* s1 = (struct student*)p1; struct student* s2 = (struct student*)p2; return 0; }