You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
3 years ago
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_strjoin.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2021/10/20 06:49:25 by narnaud #+# #+# */
|
||
|
/* Updated: 2021/11/15 10:06:33 by narnaud ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
char *ft_strjoin(const char *s1, const char *s2)
|
||
|
{
|
||
|
char *ret;
|
||
|
size_t i;
|
||
|
size_t j;
|
||
|
|
||
|
if (!s1 || !s2)
|
||
|
return (NULL);
|
||
|
ret = malloc(ft_strlen(s1) + ft_strlen(s2) + 1);
|
||
|
if (ret == NULL)
|
||
|
return (NULL);
|
||
|
i = 0;
|
||
|
while (s1[i])
|
||
|
{
|
||
|
ret[i] = s1[i];
|
||
|
i++;
|
||
|
}
|
||
|
j = 0;
|
||
|
while (s2[j])
|
||
|
{
|
||
|
ret[i] = s2[j];
|
||
|
i++;
|
||
|
j++;
|
||
|
}
|
||
|
ret[i] = '\0';
|
||
|
return (ret);
|
||
|
}
|