From ff0c230282e36de2d87e4bf717fe013183dc5bf8 Mon Sep 17 00:00:00 2001 From: VIliam Date: Wed, 28 Feb 2024 15:46:06 +0100 Subject: [PATCH] schema --- cv3/program.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 933027d..c335ce7 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -8,9 +8,7 @@ bool IsValidNumber(const char *line) { char *endFtr; strtod(line, &endFtr); - if (endFtr == line){ - return false; - } + return endFtr != line; } int main() { @@ -26,6 +24,9 @@ int main() { while (1) { if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) { + if (line[0] == '\n') { + break; + } printf("Nepodarilo sa nacitat polynom na %d mieste. \n", coefficientIndex); return 1; } @@ -38,7 +39,7 @@ int main() { } result = result * x; - coefficientIndex++; + coefficientIndex++; } printf("Vysledok je: %.2f\n", result);