aboutsummaryrefslogtreecommitdiff
path: root/src/str/ft_strsjoin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/str/ft_strsjoin.c')
-rw-r--r--src/str/ft_strsjoin.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/str/ft_strsjoin.c b/src/str/ft_strsjoin.c
index 507903b..0923bde 100644
--- a/src/str/ft_strsjoin.c
+++ b/src/str/ft_strsjoin.c
@@ -6,12 +6,20 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/04 14:30:08 by charles #+# #+# */
-/* Updated: 2020/04/04 14:45:58 by charles ### ########.fr */
+/* Updated: 2020/04/04 23:34:30 by charles ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft_str.h"
+/*
+** \brief Join null-terminated array of strings
+** \param strs Array of strings
+** \param delim String iterspersed between strings
+** \return Joined string or NULL on error
+** \note Empty strings are ignored
+*/
+
char *ft_strsjoin(char **strs, char *delim)
{
int i;
@@ -35,7 +43,7 @@ char *ft_strsjoin(char **strs, char *delim)
while (strs[++i] != NULL)
{
ft_strcat(join, strs[i]);
- if (strs[i + 1] != NULL)
+ if (*strs[i] != '\0' && strs[i + 1] != NULL)
ft_strcat(join, delim);
}
return (join);