-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_unsigned_itoa.c
More file actions
executable file
·32 lines (29 loc) · 1.16 KB
/
ft_unsigned_itoa.c
File metadata and controls
executable file
·32 lines (29 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_unsigned_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luperez <luperez@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/05 19:38:36 by luperez #+# #+# */
/* Updated: 2014/12/03 04:34:57 by luperez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_unsigned_itoa(unsigned int n)
{
char *a;
int i;
i = ft_nbrlen(n);
a = (char *)malloc(sizeof(char) * i + 1);
if (a == NULL)
return (NULL);
a[i] = '\0';
while (n / 10 != 0)
{
a[--i] = n % 10 + '0';
n = n / 10;
}
a[--i] = n % 10 + '0';
return (a);
}