From 824c048555039c45207bd153a2333a1c2e2174a2 Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Sat, 8 Apr 2023 23:14:25 +0200 Subject: [PATCH] added ft_putnstr_fd --- Makefile | 2 +- libft.h | 2 ++ put/ft_putnstr_fd.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 put/ft_putnstr_fd.c diff --git a/Makefile b/Makefile index dbfa767..e50b29e 100755 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ SRCS += mem/ft_bzero.c mem/ft_memset.c mem/ft_memchr.c mem/ft_memcpy.c \ mem/ft_memcmp.c mem/ft_memmove.c mem/ft_calloc.c mem/ft_free_split.c SRCS += put/ft_putchar_fd.c put/ft_putnbr_fd.c put/ft_putendl_fd.c \ - put/ft_putstr_fd.c + put/ft_putstr_fd.c put/ft_putnstr_fd.c SRCS += nbr/ft_nbrlen.c nbr/ft_croissant.c nbr/ft_decroissant.c nbr/ft_max.c \ nbr/ft_min.c diff --git a/libft.h b/libft.h index 20b31d4..14abb23 100755 --- a/libft.h +++ b/libft.h @@ -31,6 +31,7 @@ typedef struct s_i_slist typedef struct s_dlist { void *content; + size_t size; struct s_dlist *next; struct s_dlist *previous; } t_dlist; @@ -84,6 +85,7 @@ char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); void ft_striteri(char *s, void (*f)(unsigned int, char*)); void ft_putchar_fd(char c, int fd); void ft_putstr_fd(char *s, int fd); +void ft_putnstr_fd(size_t n, char *s, int fd); void ft_putendl_fd(char *s, int fd); void ft_putnbr_fd(int n, int fd); char *ft_append(char *s1, char *s2); diff --git a/put/ft_putnstr_fd.c b/put/ft_putnstr_fd.c new file mode 100644 index 0000000..f7ea5ca --- /dev/null +++ b/put/ft_putnstr_fd.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2021/10/22 15:10:39 by narnaud #+# #+# */ +/* Updated: 2022/03/24 09:22:49 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../libft.h" + +void ft_putnstr_fd(size_t n, char *s, int fd) +{ + if (!s) + return ; + while (n--) + ft_putchar_fd(*(s++), fd); +}