Initialization
This commit is contained in:
parent
9fdb2f3d35
commit
286056678a
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user