2018-09-13 16:25:44 -03:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2018-09-25 16:36:01 -03:00
|
|
|
bool is_float(const char *string) {
|
|
|
|
if (string == NULL) {
|
2018-09-13 16:25:44 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
char *endptr;
|
2018-09-25 16:36:01 -03:00
|
|
|
strtod(string, &endptr);
|
|
|
|
if (string == endptr) {
|
2018-09-13 16:25:44 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
while (isspace((unsigned char ) *endptr)) {
|
|
|
|
endptr++;
|
|
|
|
}
|
|
|
|
return *endptr == '\0';
|
|
|
|
}
|