addtax/src/misc.c

20 lines
338 B
C
Raw Normal View History

2018-09-13 16:25:44 -03:00
#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';
}