-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_help2.c
68 lines (61 loc) · 1.47 KB
/
ft_help2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_help2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zwalad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/29 20:55:15 by zwalad #+# #+# */
/* Updated: 2021/11/30 17:06:23 by zwalad ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putstr(char *s)
{
int i;
i = 0;
if (!s)
{
write(1, "(null)", 6);
return (6);
}
else
{
while (s[i])
{
write(1, &s[i], 1);
i++;
}
}
return (i);
}
static int ft_norm(unsigned int nbr, int size)
{
if (nbr == 0)
return (1);
while (nbr)
{
nbr /= 10;
size++;
}
return (size);
}
int ft_putuns(unsigned int nbr)
{
int size;
size = 0;
if (nbr <= 9)
ft_putchar(nbr + '0');
if (nbr > 9)
{
ft_putuns(nbr / 10);
ft_putuns(nbr % 10);
}
size = ft_norm(nbr, size);
return (size);
}
int ft_putchar(char c)
{
write(1, &c, 1);
return (1);
}