-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_itoa.c
55 lines (52 loc) · 4.18 KB
/
ft_itoa.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahabachi <ahabachi@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 16:45:06 by ahabachi #+# #+# */
/* Updated: 2022/10/06 16:45:07 by ahabachi ### ########.fr */
/* */
/* ************************************************************************** */
/* */
/* ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ */
/* ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌ */
/* ▐░▌ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▀▀▀▀█░█▀▀▀▀ */
/* ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ */
/* ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ */
/* ▐░▌ ▐░▌ ▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌ ▐░▌ */
/* ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ */
/* ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ */
/* ▐░█▄▄▄▄▄▄▄▄▄ ▄▄▄▄█░█▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌ */
/* ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░▌ ▐░▌ ▐░▌ */
/* ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀ ▀ */
/* */
/* ************************************************************************** */
/* █████████ ██████████ ██████████ ██████████ */
/* ██ ██ ██ ██ ██ ██ */
/* ██ ██ ██ ██ ██ */
/* ██ ██ ██ ██ */
/* ██ ██████████ ██████████ ██ */
/* ██ ██ ██ ██ */
/* ██ ██ ██ ██ */
/* ██ ██ ██ ██ */
/* ████████ ██████████ ██████████ ██ */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_itoa(int n)
{
int i;
char dst[12];
dst[11] = 0;
i = 10;
while (n || (i == 10))
{
dst[i--] = "9876543210123456789"[9 + n % 10];
if (-10 < n && n < 0)
dst[i--] = '-';
n = n / 10;
}
return (ft_strdup(dst + i + 1));
}