Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
pipex/libft/print/ft_putnbr_fd.c

34 lines
1.1 KiB
C
Raw Normal View History

2024-04-11 14:02:42 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */
/* Updated: 2024/02/04 14:42:15 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
void ft_putnbr_fd(int n, int fd)
{
unsigned int nbr;
if (n < 0)
{
write(fd, "-", 1);
nbr = -n;
}
else
nbr = n;
if (nbr < 10)
write(fd, &(char){nbr + '0'}, 1);
else
{
ft_putnbr_fd(nbr / 10, fd);
write(fd, &(char){nbr % 10 + '0'}, 1);
}
}