add libft, add gitignore

This commit is contained in:
2024-11-27 17:49:04 +01:00
parent b19228dccd
commit 3c467a5fd5
70 changed files with 2655 additions and 3 deletions

33
libft/ft_putnbr_fd.c Executable file
View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/11 23:27:29 by tomoron #+# #+# */
/* Updated: 2023/11/01 14:06:01 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int nb, int fd)
{
if (nb >= 10)
{
ft_putnbr_fd(nb / 10, fd);
ft_putchar_fd((nb % 10) + 48, fd);
}
else if (nb < 0)
{
if (nb == -2147483648)
write(fd, "-2147483648", 11);
else
{
ft_putchar_fd('-', fd);
ft_putnbr_fd(nb * -1, fd);
}
}
else
ft_putchar_fd((nb % 10) + 48, fd);
}