-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_util.c
More file actions
55 lines (49 loc) · 1.4 KB
/
print_util.c
File metadata and controls
55 lines (49 loc) · 1.4 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_util.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jiyseo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/18 20:22:36 by jiyseo #+# #+# */
/* Updated: 2022/05/19 17:11:50 by jiyseo ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
#include <unistd.h>
int put_char(t_info *inf, char c)
{
inf->count++;
return (write(1, &c, 1));
}
void fill_char(t_info *inf, char ch, int count)
{
while (count > 0)
{
put_char(inf, ch);
count--;
}
}
void fill_left(t_info *inf)
{
char ch;
if (inf->flag & FLAG_MINUS)
return ;
if (inf->flag & FLAG_ZERO)
ch = '0';
else
ch = ' ';
while (inf->width > 0)
{
put_char(inf, ch);
inf->width--;
}
}
void fill_right(t_info *inf)
{
while (inf->width > 0)
{
put_char(inf, ' ');
inf->width--;
}
}