removing the libft of rparodi
This commit is contained in:
parent
0391323626
commit
be6038dcc8
523 changed files with 724 additions and 3336 deletions
42
libft/src/ft_string/ft_str/ft_putnbr_fd.c
Normal file
42
libft/src/ft_string/ft_str/ft_putnbr_fd.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 09:08:01 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/07/19 21:28:41 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ft_string.h"
|
||||
|
||||
int ft_putnbr_fd(int nb, int fd)
|
||||
{
|
||||
char result[13] = {0};
|
||||
int it;
|
||||
int neg;
|
||||
|
||||
neg = 0;
|
||||
it = 12;
|
||||
if (nb == INT_MIN)
|
||||
return (ft_putstr_fd("-2147483648", fd));
|
||||
if (nb < 0)
|
||||
{
|
||||
neg = 1;
|
||||
nb = -nb;
|
||||
}
|
||||
while (nb >= 10)
|
||||
{
|
||||
result[--it] = nb % 10 + '0';
|
||||
nb /= 10;
|
||||
}
|
||||
result[--it] = nb + '0';
|
||||
if (neg)
|
||||
result[--it] = '-';
|
||||
return (ft_putstr_fd(result + it, fd));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue