-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_sec.c
55 lines (48 loc) · 1.45 KB
/
utils_sec.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
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_sec.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abkssiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/08 12:07:53 by abkssiba #+# #+# */
/* Updated: 2019/12/10 18:27:46 by abkssiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int apply_zero(int width, int len)
{
int count;
count = 0;
while (count < width - len)
{
ft_putchar_fd('0', 1);
count++;
}
return (count);
}
char *apply_precision(char *str, int pres)
{
int count;
char *g_tmp;
count = 0;
while (count < pres && str[count])
count++;
g_tmp = malloc(count + 1);
pres = -1;
while (++pres < count)
g_tmp[pres] = str[pres];
g_tmp[pres] = '\0';
return (g_tmp);
}
int apply_width(int width, int len)
{
int count;
count = 0;
while (count < width - len)
{
ft_putchar_fd(' ', 1);
count++;
}
return (count);
}