skusim osetrit fakt zly vstup

This commit is contained in:
Kamil Gejdoš 2026-03-11 13:00:21 +00:00
parent a9d8b04403
commit b3e37838ff

View File

@ -34,10 +34,13 @@ int main() {
char name[SIZE]; char name[SIZE];
int velkost_zoznamu = 0; //pocet studentov int velkost_zoznamu = 0; //pocet studentov
if ((fgets (vstup, SIZE, stdin) != NULL) && (sscanf(vstup, "%d %[^\n]", &hlasy, name) != 2)) {
printf("Nepodarilo sa nacitat nic\n");
return 0;
}
while (fgets (vstup, SIZE, stdin) != NULL) { while (fgets (vstup, SIZE, stdin) != NULL) {
//citat input, kontrola ci existuje, pridat hlasy existujucemu zaznamu //citat input, kontrola ci existuje, pridat hlasy existujucemu zaznamu
if (sscanf(vstup, "%d %[^\n]", &hlasy, name) != 2) { if (sscanf(vstup, "%d %[^\n]", &hlasy, name) != 2) {
printf("Nepodarilo sa nacitat nic\n");
break; break;
} }
existuje = 0; existuje = 0;