-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_atoi.c
29 lines (27 loc) · 1.18 KB
/
ft_atoi.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: matlopes <matlopes@student.42.rio> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 09:38:49 by matlopes #+# #+# */
/* Updated: 2023/11/07 09:43:31 by matlopes ### ########.fr */
/* */
/* ************************************************************************** */
int ft_atoi(const char *str)
{
int value;
int signal;
value = 0;
signal = 1;
while ((*str >= 9 && *str <= 13) || *str == ' ')
str++;
if (*str == '-')
signal = -1;
if (*str == '-' || *str == '+')
str++;
while (*str >= '0' && *str <= '9')
value = value * 10 + (*str++ - '0');
return (value * signal);
}