-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_s.c
More file actions
37 lines (34 loc) · 1.29 KB
/
ft_printf_s.c
File metadata and controls
37 lines (34 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_s.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mfrisby <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/11 13:14:15 by mfrisby #+# #+# */
/* Updated: 2017/07/11 13:16:36 by mfrisby ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_printf_s(t_env *e)
{
char *tmp;
char *s;
tmp = NULL;
if (e->m_l == 1)
{
ft_printf_smaj(e);
return ;
}
else
s = va_arg(e->pa, char*);
e->type = 's';
if (s == NULL)
tmp = ft_strdup("(null)");
else
tmp = ft_strdup(s);
if (tmp != NULL && e->precision >= 0 && e->precision < (int)ft_strlen(tmp)
&& tmp[e->precision])
tmp[e->precision] = '\0';
ft_printf_putflags(e, tmp);
}