From 90076f97a1de6b60968e98d6c7a8b520ebda3c8e Mon Sep 17 00:00:00 2001 From: Cabergs Charles Date: Tue, 9 Jul 2019 10:23:25 +0200 Subject: c07/c08 start, c05 faster, better, stronger --- c07/ex03/ft_strjoin.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'c07/ex03') diff --git a/c07/ex03/ft_strjoin.c b/c07/ex03/ft_strjoin.c index 1264000..ea97bb6 100644 --- a/c07/ex03/ft_strjoin.c +++ b/c07/ex03/ft_strjoin.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/07 16:14:25 by cacharle #+# #+# */ -/* Updated: 2019/07/08 11:08:00 by cacharle ### ########.fr */ +/* Updated: 2019/07/09 09:08:52 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ int my_strlen(char *str) int i; i = 0; - while(str[i]) + while (str[i]) i++; return (i); } @@ -31,12 +31,7 @@ int cummulative_strlen(int size, char **strs) i = 0; while (size > 0) { - i = 0; - while (strs[size - 1][i]) - { - i++; - len++; - } + len += my_strlen(strs[size - 1]); size--; } return (len); @@ -51,7 +46,7 @@ char *ft_strjoin(int size, char **strs, char *sep) char *join; join = (char*)malloc(sizeof(char) * (cummulative_strlen(size, strs) - + my_strlen(sep) * (size - 1))); + + my_strlen(sep) * (size - 1) + 1)); j = 0; l = 0; while (l < size) -- cgit