From f7b9265c1cedc8e89f95efe95a52a5e5b9787547 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Wed, 11 Jan 2017 18:05:47 +0100 Subject: [PATCH] ft_strbetween duplicates string in between 2 addresses --- libft/includes/libft.h | 3 ++- libft/src/lst/ft_lst_delif.c | 2 +- libft/src/math/ft_addrcmp.c | 2 +- libft/src/sstr/ft_sstrdup.c | 2 +- libft/src/sstr/ft_sstrfree.c | 2 +- libft/src/str/ft_strbetween.c | 22 ++++++++++++++++++++++ libft/src/str/ft_strnew.c | 2 +- 7 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 libft/src/str/ft_strbetween.c diff --git a/libft/includes/libft.h b/libft/includes/libft.h index 707ce85f..a58ff898 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/15 15:21:08 by jhalford ### ########.fr */ +/* Updated: 2017/01/11 16:28:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -128,6 +128,7 @@ char *ft_convert_base( 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_strbetween(char *start, char *end); 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/lst/ft_lst_delif.c b/libft/src/lst/ft_lst_delif.c index bbc67363..c331835b 100644 --- a/libft/src/lst/ft_lst_delif.c +++ b/libft/src/lst/ft_lst_delif.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */ -/* Updated: 2016/12/15 17:58:29 by jhalford ### ########.fr */ +/* Updated: 2017/01/11 16:26:31 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/math/ft_addrcmp.c b/libft/src/math/ft_addrcmp.c index f3b4f790..5c430c71 100644 --- a/libft/src/math/ft_addrcmp.c +++ b/libft/src/math/ft_addrcmp.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 15:59:10 by jhalford #+# #+# */ -/* Updated: 2016/11/14 15:59:39 by jhalford ### ########.fr */ +/* Updated: 2017/01/11 16:28:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/sstr/ft_sstrdup.c b/libft/src/sstr/ft_sstrdup.c index ac34dae4..ee8c4f5a 100644 --- a/libft/src/sstr/ft_sstrdup.c +++ b/libft/src/sstr/ft_sstrdup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 14:25:45 by jhalford #+# #+# */ -/* Updated: 2016/12/09 19:14:52 by jhalford ### ########.fr */ +/* Updated: 2017/01/11 17:49:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/sstr/ft_sstrfree.c b/libft/src/sstr/ft_sstrfree.c index ef3708fd..1e10d105 100644 --- a/libft/src/sstr/ft_sstrfree.c +++ b/libft/src/sstr/ft_sstrfree.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/05 11:53:36 by jhalford #+# #+# */ -/* Updated: 2016/12/05 16:38:33 by jhalford ### ########.fr */ +/* Updated: 2017/01/11 14:42:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/str/ft_strbetween.c b/libft/src/str/ft_strbetween.c new file mode 100644 index 00000000..c2ec5935 --- /dev/null +++ b/libft/src/str/ft_strbetween.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strbetween.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/01/11 16:26:44 by jhalford #+# #+# */ +/* Updated: 2017/01/11 16:38:13 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strbetween(char *start, char *end) +{ + char *out; + + out = ft_strnew(end - start + 1); + ft_strncpy(out, start, end - start); + return (out); +} diff --git a/libft/src/str/ft_strnew.c b/libft/src/str/ft_strnew.c index 4a60408f..56742a50 100644 --- a/libft/src/str/ft_strnew.c +++ b/libft/src/str/ft_strnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:34 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:58:35 by jhalford ### ########.fr */ +/* Updated: 2017/01/11 16:37:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */