-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintf_tools.c
84 lines (78 loc) · 1.8 KB
/
printf_tools.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf_tools.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: moboustt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/12 20:21:19 by moboustt #+# #+# */
/* Updated: 2019/12/20 21:41:45 by moboustt ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void zerolist(t_struct *list)
{
list->n = 0;
list->h = 0;
list->i = 0;
list->width = -1;
list->minus = 0;
list->zero = 0;
list->dot = 0;
list->precision = -1;
list->asterisk = 0;
}
void zerolistll(t_struct *list)
{
list->h = 0;
list->width = 0;
list->minus = 0;
list->zero = 0;
list->dot = 0;
list->precision = 0;
list->asterisk = 0;
}
char *ft_strrev(char *str)
{
int i;
int j;
char ch;
j = 0;
i = 0;
while (str[i] != '\0')
i++;
i = i - 1;
while (j < i)
{
ch = str[j];
str[j] = str[i];
str[i] = ch;
j++;
i--;
}
return (char *)(str);
}
int ft_intlen(long x)
{
if (x < 0)
x = -x;
if (x >= 1000000000)
return (10);
if (x >= 100000000)
return (9);
if (x >= 10000000)
return (8);
if (x >= 1000000)
return (7);
if (x >= 100000)
return (6);
if (x >= 10000)
return (5);
if (x >= 1000)
return (4);
if (x >= 100)
return (3);
if (x >= 10)
return (2);
return (1);
}