wip_parsing
This commit is contained in:
38
libft/put/ft_putnbr_fd.c
Normal file
38
libft/put/ft_putnbr_fd.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/03 14:33:42 by madumerg #+# #+# */
|
||||
/* Updated: 2023/11/03 14:58:11 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putnbr_fd(int n, int fd)
|
||||
{
|
||||
if (n == -2147483648)
|
||||
{
|
||||
ft_putchar_fd('-', fd);
|
||||
ft_putchar_fd('2', fd);
|
||||
n = 147483648;
|
||||
}
|
||||
if (n < 0)
|
||||
{
|
||||
ft_putchar_fd('-', fd);
|
||||
n *= -1;
|
||||
}
|
||||
if (n < 10)
|
||||
{
|
||||
ft_putchar_fd((n + '0'), fd);
|
||||
return ;
|
||||
}
|
||||
else if (n >= 10)
|
||||
{
|
||||
ft_putnbr_fd((n / 10), fd);
|
||||
ft_putnbr_fd((n % 10), fd);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user