-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprint_u_width.c
More file actions
41 lines (38 loc) · 1.46 KB
/
print_u_width.c
File metadata and controls
41 lines (38 loc) · 1.46 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_u_width.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hiroshiusui <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/31 02:38:34 by hiroshius #+# #+# */
/* Updated: 2018/01/31 02:38:35 by hiroshius ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *print_u_width(t_bag *bag, char *input)
{
char pad_character;
pad_character = ' ';
if (bag->width)
{
if (bag->zero)
pad_character = '0';
if (!bag->minus)
input = pad_left(input, bag->width, pad_character);
if (bag->minus)
input = pad_right(input, bag->width, ' ');
if (ft_strchr(input, '+') && pad_character == '0')
{
ft_strchr(input, '+')[0] = pad_character;
input[0] = '+';
}
if (ft_strchr(input, '-') && pad_character == '0')
{
ft_strchr(input, '-')[0] = pad_character;
input[0] = '-';
}
bag->minus = 0;
}
return (input);
}