-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibft_functions.c
More file actions
81 lines (74 loc) · 1.74 KB
/
libft_functions.c
File metadata and controls
81 lines (74 loc) · 1.74 KB
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
73
74
75
76
77
78
79
80
81
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libft_functions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asfaihi <asfaihi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/23 16:38:42 by asfaihi #+# #+# */
/* Updated: 2021/01/14 10:56:59 by asfaihi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putchar_g(char c, t_set *group)
{
write(1, &c, 1);
group->ret += 1;
}
void ft_putstr_g(char *s, t_set *group)
{
if (s == NULL)
return ;
while (*s)
{
ft_putchar_g(*s, group);
s++;
}
}
void ft_putnbr_g(long n, t_set *group)
{
long i;
long bn;
bn = n;
i = 1;
if (n == 0)
ft_putchar_g('0', group);
else
{
if (n < 0)
{
bn = -bn;
ft_putchar_g('-', group);
}
while ((bn / (i * 10)) != 0)
i = (i * 10);
while (i != 0)
{
ft_putchar_g((bn / i) + 48, group);
bn = (bn % i);
i = (i / 10);
}
}
}
void ft_special_putnbr(long n, t_set *group)
{
long i;
long bn;
bn = n;
i = 1;
if (n == 0)
ft_putchar_g('0', group);
else
{
if (n < 0)
bn = -bn;
while ((bn / (i * 10)) != 0)
i = (i * 10);
while (i != 0)
{
ft_putchar_g((bn / i) + 48, group);
bn = (bn % i);
i = (i / 10);
}
}
}