-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype_p.c
34 lines (31 loc) · 1.43 KB
/
type_p.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* type_p.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvarodi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/18 12:08:27 by vvarodi #+# #+# */
/* Updated: 2020/08/19 09:51:13 by vvarodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *type_p(t_buffer *b, t_flags *f, unsigned long int num, char *str)
{
char type;
type = 'p';
f->b_num_zero = (num == 0) ? 1 : 0;
f->to_write = ft_puthexa_len(b, f, num);
str = conversion_helper(b, f, str, 'p');
while (f->zeros-- > 0)
add_to_buffer(b, f, '0');
if (f->b_preci == 2 && f->precision == 0 && num == 0)
(f->width != 0) ? (b->buffer[b->buff_i] = ' ') :
(b->buffer[b->buff_i] = '\0');
else
ft_puthexa(b, f, num, &type);
if (f->b_left_aligned)
while (f->width > 0)
add_to_buffer(b, f, ' ');
return (str);
}