musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/stdlib/atoi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/atoi.c')
-rw-r--r--src/stdlib/atoi.c 15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/stdlib/atoi.c b/src/stdlib/atoi.c
new file mode 100644
index 00000000..648b154f
--- /dev/null
+++ b/src/stdlib/atoi.c
@@ -0,0 +1,15 @@
+#include <stdlib.h>
+#include <ctype.h>
+
+int atoi(const char *s)
+{
+ int n=0, neg=0;
+ while (isspace(*s)) s++;
+ switch (*s) {
+ case '-': neg=1;
+ case '+': s++;
+ }
+ while (isdigit(*s))
+ n = 10*n + *s++ - '0';
+ return neg ? -n : n;
+}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月15日 04:38:30 +0000

AltStyle によって変換されたページ (->オリジナル) /