-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminitalk_utils.c
51 lines (44 loc) · 1.31 KB
/
minitalk_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minitalk_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gvardaki <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/02 08:49:42 by gvardaki #+# #+# */
/* Updated: 2023/10/02 08:51:17 by gvardaki ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
int ft_atoi(char *str)
{
long nb;
int len;
int i;
len = 0;
while (str && str[len])
len++;
i = 0;
nb = 0;
while (i < len)
nb = (nb * 10) + (str[i++] - 48);
return (nb);
}
size_t ft_strlen(const char *s)
{
size_t i;
if (!s)
return (0);
i = 0;
while (s[i])
i++;
return (i);
}
void ft_putnbr(long nbr)
{
char temp;
if (nbr / 10 > 0)
ft_putnbr(nbr / 10);
temp = nbr % 10 + '0';
write(1, &temp, 1);
}