-
Notifications
You must be signed in to change notification settings - Fork 0
/
type_c.c
47 lines (42 loc) · 1.44 KB
/
type_c.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* type_c.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nahmed-m <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/25 11:46:40 by nahmed-m #+# #+# */
/* Updated: 2016/01/25 11:47:13 by nahmed-m ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static void ft_putstr_left(char c, t_var *e)
{
ft_putchar(c);
e->ret++;
ft_put_space(e->f_width - 1, e);
}
static void ft_putstr_right(char c, t_var *e)
{
if (e->f_zero == 0)
ft_put_space(e->f_width - 1, e);
else
ft_put_zero(e->f_width - 1, e);
ft_putchar(c);
e->ret++;
}
void type_c(t_var *e)
{
char c;
c = va_arg(e->ap, int);
if (e->f_width == 0)
{
ft_putchar(c);
e->ret++;
return ;
}
else if (e->f_width != 0 && e->f_left == 1)
ft_putstr_left(c, e);
else if (e->f_width != 0 && e->f_left == 0)
ft_putstr_right(c, e);
}