-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_itoaprintf.c
More file actions
37 lines (34 loc) · 1.21 KB
/
Copy pathft_itoaprintf.c
File metadata and controls
37 lines (34 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoaprintf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luis-ffe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/12 09:39:11 by luis-ffe #+# #+# */
/* Updated: 2023/10/12 12:00:28 by luis-ffe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_itoa(int n)
{
char *s;
long int size;
unsigned int aux;
size = countnbr(n);
s = (char *)malloc(sizeof(char) * (size + 1));
if (!s)
return (NULL);
s[size--] = '\0';
if (n == 0)
s[0] = '0';
if (n < 0)
{
aux = n * -1;
s[0] = '-';
}
else
aux = n;
s = set_nbr_str(aux, s, size);
return (s);
}