stdio: fread() and fwrite
[neatlibc.git] / atoi.c
blobfe75f9c88931e8b2a46a4ade69d8a25a55233e30
1 #include <stdlib.h>
3 int atoi(char *s)
5 int num = 0;
6 int neg = 0;
7 while (*s == ' ')
8 s++;
9 if (*s == '-' || *s == '+')
10 neg = *s++ == '-';
11 while ((unsigned) (*s - '0') <= 9u)
12 num = num * 10 + *s++ - '0';
13 return neg ? -num : num;
16 long atol(char *s)
18 return atoi(s);