-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_size_ttoa.c
35 lines (31 loc) · 1.14 KB
/
ft_size_ttoa.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_size_ttoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rabougue <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/07/07 23:35:22 by rabougue #+# #+# */
/* Updated: 2016/08/06 08:42:51 by rabougue ### ########.fr */
/* */
/* ************************************************************************** */
#include "./includes/libft.h"
static void incr(size_t *i, size_t *res)
{
while (*res != 0)
{
*res = *res / 10;
*i = *i + 1;
}
}
size_t ft_size_ttoa(size_t n)
{
size_t i;
size_t res;
i = 0;
res = n;
if (res == 0)
i = 1;
incr(&i, &res);
return (i);
}