37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_putnbr.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/07/14 16:46:16 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/07/14 16:52:22 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include <unistd.h>
|
||
|
|
||
|
void ft_putchar(char a)
|
||
|
{
|
||
|
write(1, &a, 1);
|
||
|
}
|
||
|
|
||
|
void ft_putnbr(int nb)
|
||
|
{
|
||
|
if (nb < 0)
|
||
|
{
|
||
|
ft_putchar('-');
|
||
|
ft_putnbr(-nb);
|
||
|
}
|
||
|
else if (nb > 10)
|
||
|
{
|
||
|
ft_putnbr(nb / 10);
|
||
|
ft_putchar(nb % 10 + 48);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ft_putchar(nb + 48);
|
||
|
}
|
||
|
}
|