-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_print_char.c
31 lines (28 loc) · 1.19 KB
/
ft_print_char.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_char.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mrosie <mrosie@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/19 14:08:49 by mrosie #+# #+# */
/* Updated: 2020/11/24 15:54:17 by mrosie ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_print_char(t_spec sp, char ch)
{
int printed_bytes;
printed_bytes = 1;
if (sp.flag == '-')
ft_putchar_fd(ch, 1);
while (sp.width > 1)
{
write(1, ((sp.flag == '0') ? "0" : " "), 1);
sp.width--;
printed_bytes++;
}
if (sp.flag != '-')
ft_putchar_fd(ch, 1);
return (printed_bytes);
}