Update 'cv10/program.c'

This commit is contained in:
Tamáš 2024-04-18 12:40:23 +00:00
parent 651bd07061
commit 0affccd25f

View File

@ -20,12 +20,12 @@ int main() {
if (scanf("%d\n", &maxStudents) != 1 || maxStudents <= 0) {
puts("Nespravny vstup");
return 1;
return 0;
}
while (fgets(name, MAX_NAME_LENGTH, stdin)) {
if (name[0] == '\n') break;
if (name[0] == '\n') break;
name[strcspn(name, "\n")] = '\0';
@ -34,11 +34,11 @@ int main() {
names = realloc(names, capacity * sizeof(char *));
if (names == NULL) {
perror("Failed to reallocate memory");
return 1;
return 0;
}
}
int isDuplicate = 0;
for (int i = 0; i < count; i++) {
if (strcmp(names[i], name) == 0) {
@ -51,7 +51,7 @@ int main() {
names[count] = strdup(name);
if (names[count] == NULL) {
perror("Failed to duplicate name");
return 1;
return 0;
}
count++;
}
@ -59,10 +59,10 @@ int main() {
if (count == 0) {
puts("Ziadne prihlasky");
return 1;
return 0;
}
qsort(names, count, sizeof(char *), compare);
@ -87,4 +87,4 @@ int main() {
free(names);
return 0;
}
}