initial commit
This commit is contained in:
19
src/misc.c
Normal file
19
src/misc.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#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';
|
||||
}
|
Reference in New Issue
Block a user