-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_atoi.c
29 lines (26 loc) · 1.14 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: tyeung <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/15 21:46:18 by tyeung #+# #+# */
/* Updated: 2019/07/15 21:46:21 by tyeung ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_atoi(const char *str)
{
int ispos;
ispos = 1;
while (ty_haswhitespace(*str) == 1)
str++;
if ((str[0] == '+' || (str[0] == '-')) && (ft_isdigit(str[1])))
{
if (*str == '-')
ispos = -1;
str++;
}
return (ty_atoi(str, ispos, 0, 0));
}