-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_utils.c
More file actions
58 lines (51 loc) · 1.38 KB
/
ft_printf_utils.c
File metadata and controls
58 lines (51 loc) · 1.38 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luis-ffe <luis-ffe@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/10 20:06:11 by luis-ffe #+# #+# */
/* Updated: 2023/10/12 12:27:57 by luis-ffe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_num_len(unsigned int num)
{
int len;
len = 0;
if (num == 0)
return (1);
while (num)
{
len++;
num = num / 10;
}
return (len);
}
int countnbr(int c)
{
int size;
size = 0;
if (c <= 0)
size = 1;
while (c)
{
c = c / 10;
size++;
}
return (size);
}
char *set_nbr_str(unsigned int aux, char *s, long int size)
{
while (aux > 0)
{
s[size--] = (aux % 10) + '0';
aux = aux / 10;
}
return (s);
}
int ft_putchar_fd(char c, int fd)
{
return (write (fd, &c, 1));
}