Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
pipex/libft/str/ft_atoll.c
2024-04-11 14:02:42 +02:00

36 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoll.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 09:00:27 by adjoly #+# #+# */
/* Updated: 2024/02/15 13:49:15 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
long long ft_atoll(const char *nptr)
{
char sign;
long long nbr;
sign = 1;
nbr = 0;
while ((*nptr >= 7 && *nptr <= 13) || *nptr == 32)
nptr++;
if (*nptr == '-')
{
sign *= -1;
nptr++;
}
else if (*nptr == '+')
nptr++;
while (*nptr >= '0' && *nptr <= '9')
{
nbr = nbr * 10 + (*nptr - '0');
nptr++;
}
return (nbr * sign);
}