20 lines
338 B
C
20 lines
338 B
C
#include <stdbool.h>
|
|
#include <unistd.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
|
|
bool is_float(const char *s, float dest) {
|
|
if (s == NULL) {
|
|
return false;
|
|
}
|
|
char *endptr;
|
|
dest = (float) strtod(s, &endptr);
|
|
if (s == endptr) {
|
|
return false;
|
|
}
|
|
while (isspace((unsigned char ) *endptr)) {
|
|
endptr++;
|
|
}
|
|
return *endptr == '\0';
|
|
}
|