This commit is contained in:
Oleksandr Vyshniakov 2025-03-20 17:53:15 +01:00
parent 0614d311ab
commit d9c10c0967
2 changed files with 10 additions and 7 deletions

View File

@ -33,6 +33,7 @@ int compare(const void *a, const void *b) {
int main() { int main() {
Student students[maxstudents]; Student students[maxstudents];
int count = 0; int count = 0;
int valid_data_found = 0;
char buffer[200]; char buffer[200];
while (fgets(buffer, sizeof(buffer), stdin)) { while (fgets(buffer, sizeof(buffer), stdin)) {
@ -46,9 +47,11 @@ int main() {
char name[namemax]; char name[namemax];
if (sscanf(buffer, "%d %99[^\n]", &golosa, name) != 2 || golosa <= 0) { if (sscanf(buffer, "%d %99[^\n]", &golosa, name) != 2 || golosa <= 0) {
break;; break;
} }
valid_data_found = 1;
int index = find_student(students, count, name); int index = find_student(students, count, name);
if (index != -1) { if (index != -1) {
@ -60,6 +63,11 @@ int main() {
} }
} }
if (!valid_data_found) {
printf("Nepodarilo nacitat nic\n");
return 0;
}
if (count == 0) { if (count == 0) {
printf("Chyba: Nepodarilo sa nacitat ziadny zaznam.\n"); printf("Chyba: Nepodarilo sa nacitat ziadny zaznam.\n");
return 0; return 0;
@ -74,9 +82,4 @@ int main() {
} }
return 0; return 0;
} }

Binary file not shown.