aboutsummaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-12-13 21:16:54 +0100
committerHampusM <hampus@hampusmat.com>2021-12-13 21:16:54 +0100
commitaf93edd8433634d82e855e9c9bcbca249a476977 (patch)
tree14577381b1bc101eb14080c13e624743c120a86e /utils.c
parent5afa8ec91fbbb8c20e2425d56d11cac8bd08c8a4 (diff)
refactor: clean code
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils.c b/utils.c
new file mode 100644
index 0000000..ce3dcd4
--- /dev/null
+++ b/utils.c
@@ -0,0 +1,17 @@
+#include "utils.h"
+#include <ctype.h>
+#include <string.h>
+
+/**
+ * Returns whether or not a string is a number.
+ */
+int is_number(char *str)
+{
+ size_t len = strlen(str);
+ for (int c = 0; c < len; c++)
+ {
+ if (!isdigit(str[c]))
+ return 0;
+ }
+ return 1;
+} \ No newline at end of file