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);