34 lines
1.3 KiB
C
34 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: o_ :::::: ::: */
|
|
/* ft_strjoin.c :+: / :+::+: :+: */
|
|
/* +:+ > +:++:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
|
|
/* +#+ +#+#+ +#++#+ +#+ \o/ */
|
|
/* Created: 2024/10/10 17:00:28 by whaffman #+#+# #+#+# #+# #+# | */
|
|
/* Updated: 2024/10/10 17:00:28 by whaffman ### ### ### ### / \ */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
#include "libft.h"
|
|
|
|
char *ft_strjoin(char const *s1, char const *s2)
|
|
{
|
|
char *str;
|
|
size_t len_s1;
|
|
size_t len_s2;
|
|
|
|
if (!s1 || !s2)
|
|
return (NULL);
|
|
len_s1 = ft_strlen(s1);
|
|
len_s2 = ft_strlen(s2);
|
|
str = (char *)malloc(len_s1 + len_s2 + 1);
|
|
if (!str)
|
|
return (NULL);
|
|
ft_memcpy(str, s1, len_s1);
|
|
ft_memcpy(str + len_s1, s2, len_s2);
|
|
str[len_s1 + len_s2] = '\0';
|
|
return (str);
|
|
}
|