libft/ft_putnbr_fd.c
Etienne Rey-bethbeder d73f6e1a03 z
2022-10-17 17:03:07 +02:00

32 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 10:22:16 by erey-bet #+# #+# */
/* Updated: 2022/10/17 13:50:20 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
int len;
long nl;
nl = n;
nl *= ABS(nl);
len = ft_get_size(nl);
if (n < 0)
ft_putchar_fd('-', fd);
while (len > 1)
{
--len;
ft_putchar_fd(nl / ft_power(10, len) % 10 + 48, fd);
}
ft_putchar_fd(nl % 10 + 48, fd);
}