Обновить du2/program.c
This commit is contained in:
parent
0690bb3eba
commit
2f00fb6a0b
@ -9,12 +9,21 @@ int read_double(double *value, int coef_index) {
|
||||
char line[LINE_SIZE];
|
||||
if (fgets(line, LINE_SIZE, stdin) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
line[strcspn(line, "\r\n")] = 0;
|
||||
|
||||
|
||||
if (strlen(line) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *endptr;
|
||||
*value = strtod(line, &endptr);
|
||||
if (endptr == line || (*endptr != '\0' && *endptr != '\n')) {
|
||||
|
||||
if (endptr == line || *endptr != '\0') {
|
||||
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", coef_index);
|
||||
return 0;
|
||||
exit(1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user