-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_ltoa_static.c
34 lines (31 loc) · 1.23 KB
/
ft_ltoa_static.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ltoa_static.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oadhesiv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/23 15:33:29 by oadhesiv #+# #+# */
/* Updated: 2021/01/28 14:17:35 by oadhesiv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_ltoa_static(long n)
{
static char buffer[DATA_MODEL_LONG_DECIMAL_WIDTH];
t_ulong tmp;
t_byte i;
if (n == 0)
return ("0");
ft_bzero(buffer, DATA_MODEL_LONG_DECIMAL_WIDTH);
tmp = n < 0 ? -n : n;
i = 0;
while (tmp != 0)
{
buffer[i++] = tmp % 10 + 48;
tmp /= 10;
}
if (n < 0)
buffer[i] = '-';
return (ft_strrev(buffer));
}