This commit is contained in:
lclerel- lclerel-
2026-03-06 10:56:11 +01:00
commit a29ece5577
4 changed files with 216 additions and 0 deletions

42
ex0/ft_putnbr.c Normal file
View File

@@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/05 13:17:20 by lclerel- #+# #+# */
/* Updated: 2026/03/06 10:25:12 by lclerel- ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putnbr(int nb)
{
char value;
if (nb == -2147483648)
{
write(1, "-2147483648", 11);
return ;
}
if (nb < 0)
{
write(1, "-", 1);
nb = -nb;
}
if (nb > 9)
{
ft_putnbr(nb / 10);
}
value = nb % 10 + '0';
write(1, &value, 1);
}
/*int main(void)
{
ft_putnbr(42);
ft_putnbr(-2147483647);
return (0);
}*/