-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf_utils2.c
62 lines (55 loc) · 1.56 KB
/
ft_printf_utils2.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
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ebassi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/27 15:27:59 by ebassi #+# #+# */
/* Updated: 2022/02/02 12:27:50 by ebassi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_minus(int index, char *input, int nbr, t_params *my_struct)
{
index++;
while (ft_isdigit(input[index]))
{
nbr = nbr * 10 + input[index] - '0';
index++;
}
my_struct->minus = nbr;
return (index);
}
int ft_width(int index, char *input, int nbr, t_params *my_struct)
{
while (ft_isdigit(input[index]))
{
nbr = nbr * 10 + input[index] - '0';
index++;
}
my_struct->wdth = nbr;
return (index);
}
int ft_putchar(char c)
{
write(1, &c, 1);
return (1);
}
int ft_putstr(char *str)
{
int len;
len = 0;
while (*str != '\0')
{
len += ft_putchar(*str);
str++;
}
return (len);
}
int ft_isdigit(int c)
{
if (c >= '0' && c <= '9')
return (1);
return (0);
}