Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
pipex/libft/print/printf/ft_putnbr.c

37 lines
1.2 KiB
C
Raw Normal View History

2024-04-11 14:02:42 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */
/* Updated: 2024/03/29 12:14:08 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../libft.h"
int ft_putnbr_p(int n)
{
unsigned int nbr;
int len;
len = 0;
if (n < 0)
{
len += write(1, "-", 1);
nbr = -n;
}
else
nbr = n;
if (nbr < 10)
len += write(1, &(char){nbr + '0'}, 1);
else
{
len += ft_putnbr_p(nbr / 10);
len += write(1, &(char){nbr % 10 + '0'}, 1);
}
return (len);
}