55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_put_fd.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/11/25 16:07:21 by nalebrun #+# #+# */
|
|
/* Updated: 2024/11/25 16:40:00 by nalebrun ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "../../libft.h"
|
|
|
|
void ft_put_i_fd(int n, int fd)
|
|
{
|
|
char c;
|
|
|
|
if (n == -2147483648)
|
|
{
|
|
write(fd, "-2147483648", 11);
|
|
return ;
|
|
}
|
|
if (n < 0)
|
|
{
|
|
write(fd, "-", 1);
|
|
n = -n;
|
|
}
|
|
if (n >= 10)
|
|
{
|
|
ft_put_i_fd(n / 10, fd);
|
|
}
|
|
c = (n % 10) + '0';
|
|
write(fd, &c, 1);
|
|
}
|
|
|
|
void ft_put_s_fd(char *s, int fd)
|
|
{
|
|
if (!s)
|
|
return ;
|
|
write(fd, s, ft_strlen(s));
|
|
}
|
|
|
|
void ft_put_c_fd(char c, int fd)
|
|
{
|
|
write(fd, &c, 1);
|
|
}
|
|
|
|
void ft_error(char *e)
|
|
{
|
|
ft_put_s_fd(RED, 2);
|
|
ft_put_s_fd(e, 2);
|
|
ft_put_s_fd(RESET, 2);
|
|
}
|