From 6cd148ed06cdfc570b4bc1365e46f58ca52eeab5 Mon Sep 17 00:00:00 2001 From: Matus Tokarcik Date: Thu, 21 Mar 2024 23:45:54 +0100 Subject: [PATCH] cv5 --- cv5/program.c | 17 +++++++++++------ cv5/program.exe | Bin 69470 -> 69460 bytes 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cv5/program.c b/cv5/program.c index 5d80a46..10a6f3e 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -2,6 +2,7 @@ #include #include #include +#include #define SIZE 100 #define MY_ERROR_OUTPUT stderr // chybovy vystup @@ -24,13 +25,13 @@ int compare_students(const void *a, const void *b) { return strcmp(student_a->name, student_b->name); } -int check_and_parse_line(char *line, int *votes, char *name) { +int check_line(char *line, int *votes, char *name) { // najdenie prvej medzery v retazci - char *space_pos = strchr(line, ' '); + char *space = strchr(line, ' '); // kontrola, ci sa nasla medzera - if (space_pos == NULL) { + if (space == NULL) { return 0; // neplatny riadok } @@ -40,9 +41,13 @@ int check_and_parse_line(char *line, int *votes, char *name) { if (*votes == 0) { return 0; // premena sa nepodarila } - + + //preskocenie inych znakov na zaciatku nez cislo + while (*end != '\0' && !isdigit(*end)) { + end++; //posuvam sa na dalsi znak v retazci + } // nastavenie ukazovatela name na miesto za prvou medzerou - char *name_start = space_pos + 1; + char *name_start = space + 1; // nacitanie mena memset(name, 0, SIZE); // vynulovanie pomocneho pola pre meno @@ -88,7 +93,7 @@ int main() { break; } - if (check_and_parse_line(line, &votes, name) == 0) { + if (check_line(line, &votes, name) == 0) { printf("Neplatny format"); continue; // preskoci riadok a nacita dalsi } diff --git a/cv5/program.exe b/cv5/program.exe index 13371e3f88de61ab758c6e55077ad58dc04425b9..ea547dde834e26f1ff060011b16a804b4abb7f29 100644 GIT binary patch delta 1857 zcmZXVYe*DP6vyZ8j=ODAY;9y_<=Rx(3)X7sfk6~eDWnk56EdR*g=9z+1?_$)(B5{b zDGbdbArg8Fu|-eo!v+OyrDYFdO-wDUpbd$%?SFS>yB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