From 3b4e295c1ead64e11109b65b869c723d474c8fd1 Mon Sep 17 00:00:00 2001 From: ak643du Date: Mon, 22 Apr 2024 14:11:09 +0200 Subject: [PATCH] Initialization --- cv10/program.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cv10/program.c b/cv10/program.c index e050364..be56f10 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -15,7 +15,12 @@ int main() { return 1; } - while (scanf(" %s", temp_name)!= EOF && num_accepted < max_students) { + while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) { + size_t len = strlen(temp_name); + if (len > 0 && temp_name[len-1] == '\n') { + temp_name[len-1] = '\0'; + } + int i, found = 0; for (i = 0; i < num_accepted; i++) {