first commit
This commit is contained in:
33
finish/C00/ex07/ft_putnbr.c
Normal file
33
finish/C00/ex07/ft_putnbr.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/13 13:51:06 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/16 13:26:07 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb == -214783648)
|
||||
{
|
||||
write(1, "-214783648", 10);
|
||||
return ;
|
||||
}
|
||||
if (nb < 0)
|
||||
{
|
||||
write(1, "-", 1);
|
||||
ft_putnbr(nb * -1);
|
||||
}
|
||||
else if (nb < 10)
|
||||
write(1, &(char){nb + 48}, 1);
|
||||
else
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
write(1, &(char){nb % 10 + 48}, 1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user