-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_atoli.c
30 lines (28 loc) · 1.22 KB
/
ft_atoli.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoli.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: igarbuz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/15 14:28:44 by igarbuz #+# #+# */
/* Updated: 2019/04/15 14:28:51 by igarbuz ### ########.fr */
/* */
/* ************************************************************************** */
long long int ft_atoli(const char *str)
{
long long int d;
long long int integer;
d = 1;
integer = 0;
while ((*str >= 9 && *str <= 13) || *str == 32)
str++;
if (*str == '-' && (d = -1))
str++;
else if (*str == '+')
str++;
str--;
while (++str && (*str >= 48 && *str <= 57))
integer = integer * 10 + *str - 48;
return (integer * d);
}