base struct
This commit is contained in:
54
lib/libft/srcs/print/ft_put_fd.c
Normal file
54
lib/libft/srcs/print/ft_put_fd.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user