-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_bonus.c
63 lines (56 loc) · 1.39 KB
/
utils_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gjakobss <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/09/11 17:16:35 by gjakobss #+# #+# */
/* Updated: 2021/09/11 17:16:42 by gjakobss ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
void ft_putchar(char c)
{
write(1, &c, 1);
}
int ft_strlen(const char *str)
{
int i;
i = 0;
while (str[i] != '\0')
{
i++;
}
return (i);
}
void ft_putstr(char *s)
{
int i;
i = ft_strlen(s);
write(1, s, i);
}
void ft_putnbr(int n)
{
if (n == -2147483648)
{
ft_putchar('-');
ft_putchar('2');
ft_putnbr(147483648);
return ;
}
if (n < 0)
{
ft_putchar('-');
n *= -1;
}
if (n >= 10)
{
ft_putnbr(n / 10);
n = n % 10;
}
if (n >= 0 && n < 10)
{
ft_putchar(n + '0');
}
}