RosettaCodeData/Task/Determine-if-a-string-is-numeric/C/determine-if-a-string-is-numeric.c

13 lines
228 B
C
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
#include <ctype.h>
2024-04-19 16:56:29 -07:00
#include <stdbool.h>
2023-07-01 11:58:00 -04:00
#include <stdlib.h>
2024-04-19 16:56:29 -07:00
bool isNumeric(const char *s) {
if (s == NULL || *s == '\0' || isspace(*s)) {
return false;
}
char *p;
strtod(s, &p);
2023-07-01 11:58:00 -04:00
return *p == '\0';
}