-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_atoll.c
34 lines (31 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoll.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kokaimov <kokaimov@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/23 18:45:14 by kokaimov #+# #+# */
/* Updated: 2024/02/23 18:45:14 by kokaimov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
long long int ft_atoll(const char *nptr)
{
short i;
short minus;
long long int ans;
i = 0;
minus = 1;
ans = 0;
while (nptr[i] == ' ' || nptr[i] == '\t' || nptr[i] == '\n'
|| nptr[i] == '\v' || nptr[i] == '\f' || nptr[i] == '\r')
i++;
if (nptr[i] == '-')
minus = -1;
if (nptr[i] == '-' || nptr[i] == '+')
i++;
while (nptr[i] >= '0' && nptr[i] <= '9')
ans = ans * 10 + (nptr[i++] - '0');
return (ans * minus);
}