-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf_utils.c
54 lines (47 loc) · 1.4 KB
/
ft_printf_utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tpeters <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/01 01:26:32 by tpeters #+# #+# */
/* Updated: 2022/09/17 13:10:14 by tpeters ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int spacing(int cur_len, int min_size, char fill)
{
int size;
size = 0;
while (min_size > cur_len)
{
ft_putchar_fd(fill, 1);
min_size--;
size++;
}
return (size);
}
int hex_len(unsigned long in, int precision)
{
int len;
len = 0;
if (!in && precision)
return (1);
while (in)
{
in /= 16;
len++;
}
if (precision > len)
return (precision);
return (len);
}
int find_first_of(const char *c, char const *set)
{
int i;
i = 0;
while (c[i] && !char_in_set(c[i], set))
i++;
return (i);
}