-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
72 lines (63 loc) · 1.58 KB
/
utils.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oqaroot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/17 17:20:38 by oqaroot #+# #+# */
/* Updated: 2024/10/17 17:20:40 by oqaroot ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
write(1, &str[i++], 1);
}
int ft_atoi(const char *str)
{
int i;
int sign;
int nbr;
i = 0;
sign = 1;
nbr = 0;
while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13))
{
i++;
}
while (str[i] == '-' || str[i] == '+')
{
if (str[i] == '-')
sign = sign * -1;
i++;
}
while (str[i] >= '0' && str[i] <= '9')
{
nbr = (nbr * 10) + (str[i] - '0');
i++;
}
return (nbr * sign);
}
void ft_putnbr(int n)
{
long lng;
lng = n;
if (lng > 9)
ft_putnbr(lng / 10);
ft_putchar(lng % 10 + '0');
}
void ft_putchar(char c)
{
write(1, &c, 1);
}
int ft_isdigit(int c)
{
if (c >= '0' && c <= '9')
return (1);
else
return (0);
}