Update du4/program.c
This commit is contained in:
parent
4bbb299f45
commit
c2e16f54da
@ -1,6 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAX_NAME 100
|
||||
#define MAX_ENTRIES 100
|
||||
@ -49,16 +50,20 @@ int main() {
|
||||
int has_data = 0;
|
||||
|
||||
while (fgets(line, sizeof(line), stdin)) {
|
||||
// Preskočí prázdne riadky
|
||||
if (strlen(line) <= 1) continue;
|
||||
|
||||
if (sscanf(line, "%d %[^\n]", &votes, name) != 2 || votes < 0) {
|
||||
break;
|
||||
continue; // Namiesto prerušenia len ignoruje neplatné riadky
|
||||
}
|
||||
|
||||
Student *student = find_or_add(name);
|
||||
if (student) student->votes += votes;
|
||||
has_data = 1;
|
||||
}
|
||||
|
||||
if (!has_data) {
|
||||
printf("Chyba: Nebol zadany platny vstup.\n");
|
||||
printf("Nepodarilo nacitat nic\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user