From 81343980beaa658ebc4a14105f514061e82d6818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Fri, 18 Oct 2024 15:20:56 +0200 Subject: [PATCH] ft_putstr_fd: initial implementation --- Makefile | 5 +++-- ft_putstr_fd.c | 36 ++++++++++++++++++++++++++++++++++++ libft.h | 3 ++- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 ft_putstr_fd.c diff --git a/Makefile b/Makefile index f012d9b..6d52059 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: kcolin +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/14 13:43:59 by kcolin #+# #+# # -# Updated: 2024/10/18 14:27:44 by kcolin ### ########.fr # +# Updated: 2024/10/18 14:36:09 by kcolin ### ########.fr # # # # **************************************************************************** # @@ -42,7 +42,8 @@ SOURCES = ft_isalpha.c \ ft_itoa.c \ ft_strmapi.c \ ft_striteri.c \ - ft_putchar_fd.c + ft_putchar_fd.c \ + ft_putstr_fd.c OBJECTS = $(SOURCES:.c=.o) CC = gcc diff --git a/ft_putstr_fd.c b/ft_putstr_fd.c new file mode 100644 index 0000000..0e4b9a1 --- /dev/null +++ b/ft_putstr_fd.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kcolin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/18 14:33:21 by kcolin #+# #+# */ +/* Updated: 2024/10/18 15:17:57 by kcolin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include + +void ft_putstr_fd(char *s, int fd) +{ + write(fd, s, ft_strlen(s)); +} + +/* +int main(int argc, char **argv) +{ + if (argc > 1) + { + int i = 1; + while (i < argc) + { + ft_putstr_fd(argv[i], 1); + ft_putchar_fd('\n', 1); + i++; + } + } + return (0); +} +*/ diff --git a/libft.h b/libft.h index a3ec5ec..50a3691 100644 --- a/libft.h +++ b/libft.h @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/15 10:11:54 by kcolin #+# #+# */ -/* Updated: 2024/10/18 11:33:58 by kcolin ### ########.fr */ +/* Updated: 2024/10/18 15:20:07 by kcolin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,5 +58,6 @@ 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); #endif