philosopher/utils/ft_itoa.c
2023-03-24 16:41:34 +01:00

30 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:12:52 by erey-bet #+# #+# */
/* Updated: 2023/03/24 16:35:39 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h"
char *ft_itoa(long long n)
{
char *str;
long long q;
long long i;
q = 10;
while (n / q > 0)
q = q * 10;
str = malloc(sizeof(char) * q + 1);
i = 0;
while (q > 0)
str[i++] = (n / q % 10) + 48;
return (str);
}