copi new gnl en bonus

This commit is contained in:
hugodu69
2019-12-27 12:36:31 +01:00
parent d7907b5706
commit 11da29a020
7 changed files with 203 additions and 217 deletions

View File

@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils_bonus.c :+: :+: :+: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/16 14:08:47 by hulamy #+# #+# */
/* Updated: 2019/12/16 14:10:54 by hulamy ### ########.fr */
/* Created: 2019/12/11 00:26:54 by hulamy #+# #+# */
/* Updated: 2019/12/11 00:57:19 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -71,3 +71,26 @@ size_t ft_strlen(const char *str)
i++;
return (i);
}
char *ft_strjoinfree(char const *s1, char const *s2)
{
char *str;
int len;
int j;
if (!s1 || !s2)
return (NULL);
len = ft_strlen(s1) + ft_strlen(s2);
if (!(str = (char *)malloc(sizeof(char) * (len + 1))))
return (NULL);
len = 0;
j = 0;
while (s1[j] != '\0')
str[len++] = s1[j++];
j = 0;
while (s2[j] != '\0')
str[len++] = s2[j++];
str[len] = '\0';
free((char*)s1);
return (str);
}