-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_atoll.c
37 lines (34 loc) · 1.18 KB
/
ft_atoll.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
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoll.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zhabri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/22 10:25:53 by zhabri #+# #+# */
/* Updated: 2023/01/02 13:49:09 by zhabri ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
long long ft_atoll(const char *nptr)
{
int i;
long long nb;
int neg;
i = 0;
nb = 0;
neg = 1;
if (nptr[i] == '-' || nptr[i] == '+')
{
if (nptr[i] == '-')
neg = -1;
i++;
}
while (ft_isdigit(nptr[i]))
{
nb *= 10;
nb += nptr[i] - '0';
i++;
}
return (nb * neg);
}