Das ist meine read_double-Funktion. Warum muss ich nach "flush_buff()" suchen oder was bewirkt das? Ich kann es irgendwie nicht herausfinden. Könnte ich nicht einfach flush_buff() schreiben und dann DBL_MIN zurückgeben?Wie wirkt sich die Negation! My_function() auf meine Funktion in C aus?
double read_double(void) {
double x;
int c, status;
printf("Insert double: ");
status = scanf("%lf", &x);
if (status == EOF || (c = getchar()) == EOF) {
return DBL_MIN;
}
if (status != 1 || c != '\n' || x < DBL_MIN) {
if (!flush_buff()) { /*What is the purpose of this?*/
return DBL_MIN;
}
return DBL_MAX;
}
return x;
}
Die flush_buff Funktion:
int flush_buff(void) {
int c;
while ((c = getchar()) != '\n' && c != EOF) {}
return c != EOF;
}
BTW 'x> DBL_MAX' werden nie wahr. – BLUEPIXY