This commit is contained in:
rzy
2026-08-31 02:16:33 +02:00
commit 94cd5aac51
25 changed files with 705 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rzy <ry@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/08/23 23:34:29 by rzy #+# #+# */
/* Updated: 2026/08/23 23:37:29 by rzy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_isspace(char c)
{
return (c == ' ' || (c >= '\t' && c <= '\r'));
}
int ft_atoi(const char *nptr)
{
int result;
int sign;
int i;
result = 0;
sign = 1;
i = 0;
while (ft_isspace(nptr[i]))
++i;
if (nptr[i] == '+' || nptr[i] == '-')
{
if (nptr[i] == '-')
sign = -1;
++i;
}
while (ft_isdigit(nptr[i]))
{
result = (result * 10) + (nptr[i] - '0');
++i;
}
return (result * sign);
}