From af93edd8433634d82e855e9c9bcbca249a476977 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 13 Dec 2021 21:16:54 +0100 Subject: refactor: clean code --- utils.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 utils.c (limited to 'utils.c') 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 +#include + +/** + * 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 -- cgit v1.2.3-18-g5258