adding other files cause i put the git on the wrong

This commit is contained in:
Maoake Teriierooiterai
2026-01-07 08:14:22 +01:00
parent 2b255b94da
commit ca732b1b97
13 changed files with 31 additions and 126 deletions

42
parsing/ft_atoi.c Normal file
View File

@@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 18:28:17 by mteriier #+# #+# */
/* Updated: 2025/12/08 19:30:48 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
static int calcul_sign(char c)
{
if (c == '-')
return (-1);
return (1);
}
int ft_atoi(const char *nptr)
{
size_t i;
int sign;
int tmp;
i = 0;
sign = 1;
tmp = 0;
while ((nptr[i] >= 9 && nptr[i] <= 13) || nptr[i] == ' ')
i++;
sign = calcul_sign(nptr[i]);
if (nptr[i] == '-' || nptr[i] == '+')
i++;
while (nptr[i] >= '0' && nptr[i] <= '9')
{
tmp = tmp * 10 + nptr[i] - '0';
i++;
}
return (tmp * sign);
}