-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_atoll.c
More file actions
38 lines (35 loc) · 1.25 KB
/
ft_atoll.c
File metadata and controls
38 lines (35 loc) · 1.25 KB
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
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoll.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sde-silv <sde-silv@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/25 15:26:06 by sde-silv #+# #+# */
/* Updated: 2023/10/25 15:26:41 by sde-silv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
long long ft_atoll(const char *nptr)
{
int i;
long long n;
int sign;
i = 0;
sign = 1;
n = 0;
while (nptr[i] && ft_isspace(nptr[i]) != 0)
i ++;
if (nptr[i] == '-' || nptr[i] == '+')
{
if (nptr[i] == '-')
sign = -1;
i ++;
}
while (nptr[i] && nptr[i] >= '0' && nptr[i] <= '9')
{
n = (n * 10) + (nptr[i] - 48);
i ++;
}
return (sign * n);
}