Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_atoi.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_atoi.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: raphalme <raphalme@student.42.fr> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2025/12/29 18:54:00 by raphalme #+# #+# */
9
/* Updated: 2026/04/14 11:01:30 by raphalme ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
22
int
ft_atoi
(
const
char
*str)
23
{
24
int
res;
25
int
sign;
26
int
i;
27
28
res = 0;
29
sign = 1;
30
i = 0;
31
while
((str[i] >= 9 && str[i] <= 13) || str[i] == 32)
32
i++;
33
if
(str[i] ==
'-'
|| str[i] ==
'+'
)
34
{
35
if
(str[i] ==
'-'
)
36
sign = -1;
37
i++;
38
}
39
while
(str[i] >=
'0'
&& str[i] <=
'9'
)
40
{
41
res = res * 10 + (str[i] -
'0'
);
42
i++;
43
}
44
return
(res * sign);
45
}
ft_atoi
int ft_atoi(const char *str)
Converts an ASCII string to an int value.
Definition
ft_atoi.c:22
src
ft_atoi.c
Generated by
1.9.8