Add all git folders
This commit is contained in:
38
C_Piscine_C_04/git/ex02/ft_putnbr.c
Normal file
38
C_Piscine_C_04/git/ex02/ft_putnbr.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/13 09:24:02 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/13 14:47:24 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (nb == -2147483648)
|
||||
write(1, "-2147483648", 11);
|
||||
else if (nb >= 10)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putnbr(nb % 10);
|
||||
}
|
||||
else if (nb < 0)
|
||||
{
|
||||
write(1, "-", 1);
|
||||
nb *= -1;
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putnbr(nb % 10);
|
||||
}
|
||||
else if (nb >= 0)
|
||||
{
|
||||
c = nb + '0';
|
||||
write(1, &c, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user