42 lines
1.2 KiB
C
42 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_putnbr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/19 14:48:52 by cchauvet #+# #+# */
|
|
/* Updated: 2022/07/25 10:00:23 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <unistd.h>
|
|
|
|
void ft_putchar(char c)
|
|
{
|
|
write(1, &c, 1);
|
|
}
|
|
|
|
void ft_putnbr(int nbr)
|
|
{
|
|
if (nbr == -2147483648)
|
|
{
|
|
ft_putnbr(-2);
|
|
ft_putnbr(147483648);
|
|
}
|
|
else if (nbr < 0)
|
|
{
|
|
ft_putchar('-');
|
|
ft_putnbr(-nbr);
|
|
}
|
|
else if (nbr > 9)
|
|
{
|
|
ft_putnbr(nbr / 10);
|
|
ft_putnbr(nbr % 10);
|
|
}
|
|
else
|
|
{
|
|
ft_putchar(nbr + 48);
|
|
}
|
|
}
|