From ebfef066fcb715026631d392d3cda6c7ef2c655a Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Tue, 13 Dec 2016 12:58:51 +0100 Subject: [PATCH] ft_strappend --- libft/includes/libft.h | 3 ++- libft/src/ft_printf/ft_printf.c | 2 +- libft/src/ft_printf/ft_transform.c | 2 +- libft/src/str/ft_strappend.c | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 libft/src/str/ft_strappend.c diff --git a/libft/includes/libft.h b/libft/includes/libft.h index 8877379d..8eb991cc 100644 --- a/libft/includes/libft.h +++ b/libft/includes/libft.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:02:46 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:18:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -126,6 +126,7 @@ char *ft_convert_base( char *str, char *base_from, char *base_to, char *flags); char *ft_strcatf(char *s1, const char *s2); char *ft_strinsert(char *str, char c, int n); +int ft_strappend(char **dst, char *src); char *ft_itoa_base(int nbr, char *base, char *flags); char *ft_lltoa_base(long long nbr, char *base, char *flags); diff --git a/libft/src/ft_printf/ft_printf.c b/libft/src/ft_printf/ft_printf.c index 44ef8a8c..bf9e1d85 100644 --- a/libft/src/ft_printf/ft_printf.c +++ b/libft/src/ft_printf/ft_printf.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ -/* Updated: 2016/12/12 11:57:28 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 11:20:36 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/ft_printf/ft_transform.c b/libft/src/ft_printf/ft_transform.c index f8115517..6651e619 100644 --- a/libft/src/ft_printf/ft_transform.c +++ b/libft/src/ft_printf/ft_transform.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */ -/* Updated: 2016/12/10 16:51:11 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 11:19:29 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/str/ft_strappend.c b/libft/src/str/ft_strappend.c new file mode 100644 index 00000000..761ca683 --- /dev/null +++ b/libft/src/str/ft_strappend.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strappend.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/12/13 12:16:31 by jhalford #+# #+# */ +/* Updated: 2016/12/13 12:18:41 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_strappend(char **dst, char *src) +{ + char *out; + + if (!(out = ft_strjoin(*dst, src))) + return (-1); + ft_strdel(*dst); + *dst = out; + return (0); +}