osetrit zly vstup

This commit is contained in:
Kamil Gejdoš 2026-03-11 12:58:14 +00:00
parent 3e4f77dd18
commit a9d8b04403

View File

@ -36,7 +36,10 @@ int main() {
while (fgets (vstup, SIZE, stdin) != NULL) {
//citat input, kontrola ci existuje, pridat hlasy existujucemu zaznamu
if (sscanf(vstup, "%d %[^\n]", &hlasy, name) != 2) break;
if (sscanf(vstup, "%d %[^\n]", &hlasy, name) != 2) {
printf("Nepodarilo sa nacitat nic\n");
break;
}
existuje = 0;
for (int i = 0; i < velkost_zoznamu; i++) {
if (strcmp (name, studenti[i].name) == 0) {