philosopher/philo/utils/ft_lltos.c
Etienne Rey-bethbeder 3f0ec62059 corrigé mixed up
2023-04-06 14:02:19 +02:00

39 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa_bozo.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:12:52 by erey-bet #+# #+# */
/* Updated: 2023/03/27 15:48:37 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h"
int ft_lltos(char *str, long long n)
{
long long v;
long long q;
long long i;
i = 0;
v = n;
if (n < 0)
{
str[i++] = '-';
v *= -1;
}
q = 1;
while (n / q > 9)
q *= 10;
while (q > 0)
{
str[i++] = (n / q % 10) + 48;
q /= 10;
}
str[i] = '\0';
return (i);
}