push_swap/libft/ft_putnbr_fd.c
Etienne Rey-bethbeder e35b9d3e9e Add libft
2022-12-08 18:06:06 +01:00

33 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/18 17:32:20 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
int len;
long nl;
nl = n;
if (nl < 0)
nl *= -1;
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);
}