-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointer_precision.c
More file actions
47 lines (43 loc) · 1.4 KB
/
Copy pathpointer_precision.c
File metadata and controls
47 lines (43 loc) · 1.4 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* numbers_precision.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pgomez-a <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/11 08:45:01 by pgomez-a #+# #+# */
/* Updated: 2021/03/11 10:25:07 by pgomez-a ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static void man_zero(char **itoa, char **pre)
{
if (**pre == '0' || **pre == '\0')
{
free(*itoa);
(*itoa) = ft_strdup("");
}
}
int ptr_man_pre(char **itoa, char **pre)
{
char *temp;
int num_p;
int len_i;
(**pre) = '\0';
(*pre)++;
if (ft_atoi(*itoa) == 0 && (**pre <= '0' || **pre > '9'))
man_zero(itoa, pre);
else
{
num_p = ft_atoi(*pre);
len_i = ft_strlen(*itoa);
while (num_p > len_i)
{
temp = *itoa;
(*itoa) = ft_strjoin("0", *itoa);
free(temp);
num_p--;
}
}
return (1);
}