Test
This commit is contained in:
BIN
ex0/.ft_putnbr.c.swp
Normal file
BIN
ex0/.ft_putnbr.c.swp
Normal file
Binary file not shown.
41
ex0/ft_putnbr.c
Normal file
41
ex0/ft_putnbr.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/03/05 13:17:20 by lclerel- #+# #+# */
|
||||
/* Updated: 2026/03/05 13:37:09 by lclerel- ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
char value;
|
||||
|
||||
if (nb == -2147483648)
|
||||
{
|
||||
write(1, "-2147483648", 11);
|
||||
return ;
|
||||
}
|
||||
else if (nb < 0)
|
||||
{
|
||||
write(1, "-", 1);
|
||||
nb = -nb;
|
||||
}
|
||||
else if (nb > 9)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
}
|
||||
value = nb % 10 + '0';
|
||||
write(1, &value, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ft_putnbr(42);
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user