-
Notifications
You must be signed in to change notification settings - Fork 0
/
aux.c
52 lines (47 loc) · 1.41 KB
/
aux.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aux.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: juhagon <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/15 12:46:43 by juhagon #+# #+# */
/* Updated: 2021/12/15 12:48:20 by juhagon ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
int ft_atoi(const char *s)
{
long int tmp;
long int nmb;
long int sign;
tmp = 0;
nmb = 0;
sign = 0;
while (s[tmp] == 32 || s[tmp] == '\n' || \
s[tmp] == '\v' || s[tmp] == '\r' || s[tmp] == '\t' || s[tmp] == '\f')
tmp++;
if (s[tmp] == '+')
tmp++;
else if (s[tmp] == '-')
{
tmp++;
sign = 1;
}
while (s[tmp] >= '0' && s[tmp] <= '9')
{
nmb = nmb * 10 + s[tmp] - '0';
tmp++;
}
if (sign == 1)
nmb = -nmb;
return (nmb);
}
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}