From c57ab4e5bd4d0bfc7ca8a3a9a466687f7b191083 Mon Sep 17 00:00:00 2001 From: Miloslav Macko Date: Mon, 15 Apr 2024 22:11:19 +0200 Subject: [PATCH] 121 --- cv10/program.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cv10/program.c b/cv10/program.c index 7bb14ad..cbe2085 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -42,7 +42,10 @@ int main() { // Výpis prijatých a neprijatých študentov int max_students; - scanf("%d", &max_students); + if (scanf("%d\n", &max_students) != 1) { + fprintf(stderr, "Error reading the maximum number of students\n"); + return 1; + } printf("Prijati studenti:\n"); for (int i = 0; i < max_students && i < pocet_mien_v_poli; i++) {