summaryrefslogtreecommitdiff
path: root/src/utils/string.c
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-01-27 01:25:24 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-01-27 01:25:24 +0330
commit64331c144518b8ab1c3cf08473771e0d3f14f67b (patch)
treec378fccbddcc4e0972a7a426b4bf464efc1129bf /src/utils/string.c
parentbb87887ec288f341256d324f271bac6267fc83f4 (diff)
add print_u64 to be able to print u64 numbers
Diffstat (limited to 'src/utils/string.c')
-rw-r--r--src/utils/string.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/string.c b/src/utils/string.c
index 81be415..e01d1b6 100644
--- a/src/utils/string.c
+++ b/src/utils/string.c
@@ -1,5 +1,6 @@
#include "string.h"
+#include <stdint.h>
#include <string.h>
size_t searchInStringArray(const char *array[], size_t array_size,
@@ -12,3 +13,20 @@ size_t searchInStringArray(const char *array[], size_t array_size,
}
return array_size;
}
+
+uint64_t decimalToU64(char *str_begin, char *str_end, bool *success) {
+ uint64_t result = 0;
+
+ while (str_begin < str_end) {
+ if (*str_begin < '0' || *str_begin > '9') {
+ *success = false;
+ return 0;
+ }
+ result *= 10;
+ result += *str_begin - '0';
+ str_begin += 1;
+ }
+
+ *success = true;
+ return result;
+}