39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_strjoin.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/09/29 11:20:27 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/10/10 14:42:41 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "printf.h"
|
||
|
|
||
|
char *ft_strjoin(char *s1, char *s2)
|
||
|
{
|
||
|
size_t i;
|
||
|
size_t j;
|
||
|
char *out;
|
||
|
|
||
|
if (s1 == NULL || s2 == NULL)
|
||
|
return (NULL);
|
||
|
out = malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char));
|
||
|
i = 0;
|
||
|
while (s1[i] != 0)
|
||
|
{
|
||
|
out[i] = s1[i];
|
||
|
i++;
|
||
|
}
|
||
|
j = 0;
|
||
|
while (s2[j] != 0)
|
||
|
{
|
||
|
out[i + j] = s2[j];
|
||
|
j++;
|
||
|
}
|
||
|
out[i + j] = 0;
|
||
|
return (out);
|
||
|
}
|