diff --git a/cv10/program.c b/cv10/program.c index 7648cbc..0635dcf 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -24,11 +24,10 @@ int main() { memset(names, 0, sizeof(names)); - while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) { + while (fgets(temp_name, sizeof(temp_name), stdin)!= NULL && num_accepted < max_students) { int i, found = 0; - // Remove the newline character from the temp_name array temp_name[strcspn(temp_name, "\n")] = '\0'; for (i = 0; i < num_accepted; i++) { @@ -38,15 +37,15 @@ int main() { } } - if (!found) { + if (!found && num_accepted < MAX_STUDENTS) { strcpy(names[num_accepted], temp_name); num_accepted++; } num_students++; - // Check if we have reached the maximum number of accepted students + if (num_accepted == max_students) { - break; // Exit the loop + break; } }